From a369a68a406642c469d8cf77b7f9e640993e9b79 Mon Sep 17 00:00:00 2001 From: devhl Date: Mon, 27 May 2024 14:28:37 -0400 Subject: [PATCH] added framework support --- .github/workflows/openapi-generator.yaml | 9 + .github/workflows/samples-dotnet-net47.yaml | 32 + appveyor.yml | 9 + .../csharp-generichost-net4.7-allOf.yaml | 13 + .../csharp-generichost-net4.7-anyOf.yaml | 13 + ...arp-generichost-net4.7-anyOfNoCompare.yaml | 13 + .../csharp-generichost-net4.7-formModels.yaml | 16 + .../csharp-generichost-net4.7-oneOf.yaml | 13 + ...generichost-net4.7-useDateTimeForDate.yaml | 10 + bin/configs/csharp-generichost-net4.7.yaml | 13 + .../generichost/ApiResponse`1.mustache | 2 +- .../libraries/generichost/AsModel.mustache | 2 +- .../generichost/ClientUtils.mustache | 4 +- .../generichost/RateLimitProvider`1.mustache | 5 - .../csharp/libraries/generichost/api.mustache | 10 +- .../resources/csharp/netcore_project.mustache | 31 +- .../generichost/net4.7/AllOf/.gitignore | 362 ++ .../net4.7/AllOf/.openapi-generator-ignore | 23 + .../net4.7/AllOf/.openapi-generator/FILES | 40 + .../net4.7/AllOf/.openapi-generator/VERSION | 1 + .../net4.7/AllOf/Org.OpenAPITools.sln | 27 + .../csharp/generichost/net4.7/AllOf/README.md | 1 + .../generichost/net4.7/AllOf/api/openapi.yaml | 71 + .../generichost/net4.7/AllOf/appveyor.yml | 9 + .../net4.7/AllOf/docs/apis/DefaultApi.md | 95 + .../net4.7/AllOf/docs/models/Adult.md | 14 + .../net4.7/AllOf/docs/models/Child.md | 15 + .../net4.7/AllOf/docs/models/Person.md | 12 + .../net4.7/AllOf/docs/scripts/git_push.ps1 | 75 + .../net4.7/AllOf/docs/scripts/git_push.sh | 49 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 58 + .../Api/DefaultApiTests.cs | 65 + .../Api/DependencyInjectionTests.cs | 103 + .../Org.OpenAPITools.Test/Model/AdultTests.cs | 65 + .../Org.OpenAPITools.Test/Model/ChildTests.cs | 74 + .../Model/PersonTests.cs | 103 + .../Org.OpenAPITools.Test.csproj | 19 + .../AllOf/src/Org.OpenAPITools.Test/README.md | 0 .../src/Org.OpenAPITools/Api/DefaultApi.cs | 355 ++ .../AllOf/src/Org.OpenAPITools/Api/IApi.cs | 15 + .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 170 + .../Org.OpenAPITools/Client/ClientUtils.cs | 329 ++ .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 131 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 55 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 57 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 71 + .../AllOf/src/Org.OpenAPITools/Model/Adult.cs | 205 + .../AllOf/src/Org.OpenAPITools/Model/Child.cs | 227 + .../src/Org.OpenAPITools/Model/Person.cs | 247 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 33 + .../AllOf/src/Org.OpenAPITools/README.md | 177 + .../generichost/net4.7/AnyOf/.gitignore | 362 ++ .../net4.7/AnyOf/.openapi-generator-ignore | 23 + .../net4.7/AnyOf/.openapi-generator/FILES | 40 + .../net4.7/AnyOf/.openapi-generator/VERSION | 1 + .../net4.7/AnyOf/Org.OpenAPITools.sln | 27 + .../csharp/generichost/net4.7/AnyOf/README.md | 1 + .../generichost/net4.7/AnyOf/api/openapi.yaml | 42 + .../generichost/net4.7/AnyOf/appveyor.yml | 9 + .../net4.7/AnyOf/docs/apis/DefaultApi.md | 90 + .../net4.7/AnyOf/docs/models/Apple.md | 10 + .../net4.7/AnyOf/docs/models/Banana.md | 10 + .../net4.7/AnyOf/docs/models/Fruit.md | 10 + .../net4.7/AnyOf/docs/scripts/git_push.ps1 | 75 + .../net4.7/AnyOf/docs/scripts/git_push.sh | 49 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 58 + .../Api/DefaultApiTests.cs | 64 + .../Api/DependencyInjectionTests.cs | 103 + .../Org.OpenAPITools.Test/Model/AppleTests.cs | 65 + .../Model/BananaTests.cs | 65 + .../Org.OpenAPITools.Test/Model/FruitTests.cs | 65 + .../Org.OpenAPITools.Test.csproj | 19 + .../AnyOf/src/Org.OpenAPITools.Test/README.md | 0 .../src/Org.OpenAPITools/Api/DefaultApi.cs | 329 ++ .../AnyOf/src/Org.OpenAPITools/Api/IApi.cs | 15 + .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 170 + .../Org.OpenAPITools/Client/ClientUtils.cs | 329 ++ .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 131 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 55 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 57 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 71 + .../AnyOf/src/Org.OpenAPITools/Model/Apple.cs | 174 + .../src/Org.OpenAPITools/Model/Banana.cs | 172 + .../AnyOf/src/Org.OpenAPITools/Model/Fruit.cs | 242 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 33 + .../AnyOf/src/Org.OpenAPITools/README.md | 177 + .../net4.7/AnyOfNoCompare/.gitignore | 362 ++ .../AnyOfNoCompare/.openapi-generator-ignore | 23 + .../AnyOfNoCompare/.openapi-generator/FILES | 40 + .../AnyOfNoCompare/.openapi-generator/VERSION | 1 + .../AnyOfNoCompare/Org.OpenAPITools.sln | 27 + .../net4.7/AnyOfNoCompare/README.md | 1 + .../net4.7/AnyOfNoCompare/api/openapi.yaml | 42 + .../net4.7/AnyOfNoCompare/appveyor.yml | 9 + .../AnyOfNoCompare/docs/apis/DefaultApi.md | 90 + .../AnyOfNoCompare/docs/models/Apple.md | 10 + .../AnyOfNoCompare/docs/models/Banana.md | 10 + .../AnyOfNoCompare/docs/models/Fruit.md | 10 + .../AnyOfNoCompare/docs/scripts/git_push.ps1 | 75 + .../AnyOfNoCompare/docs/scripts/git_push.sh | 49 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 58 + .../Api/DefaultApiTests.cs | 64 + .../Api/DependencyInjectionTests.cs | 103 + .../Org.OpenAPITools.Test/Model/AppleTests.cs | 65 + .../Model/BananaTests.cs | 65 + .../Org.OpenAPITools.Test/Model/FruitTests.cs | 65 + .../Org.OpenAPITools.Test.csproj | 19 + .../src/Org.OpenAPITools.Test/README.md | 0 .../src/Org.OpenAPITools/Api/DefaultApi.cs | 329 ++ .../src/Org.OpenAPITools/Api/IApi.cs | 15 + .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 170 + .../Org.OpenAPITools/Client/ClientUtils.cs | 314 + .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 131 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 55 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 57 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 71 + .../src/Org.OpenAPITools/Model/Apple.cs | 173 + .../src/Org.OpenAPITools/Model/Banana.cs | 171 + .../src/Org.OpenAPITools/Model/Fruit.cs | 241 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 32 + .../src/Org.OpenAPITools/README.md | 176 + .../generichost/net4.7/FormModels/.gitignore | 362 ++ .../FormModels/.openapi-generator-ignore | 23 + .../FormModels/.openapi-generator/FILES | 280 + .../FormModels/.openapi-generator/VERSION | 1 + .../net4.7/FormModels/Org.OpenAPITools.sln | 27 + .../generichost/net4.7/FormModels/README.md | 1 + .../net4.7/FormModels/api/openapi.yaml | 2980 ++++++++++ .../net4.7/FormModels/appveyor.yml | 9 + .../FormModels/docs/apis/AnotherFakeApi.md | 99 + .../net4.7/FormModels/docs/apis/DefaultApi.md | 429 ++ .../net4.7/FormModels/docs/apis/FakeApi.md | 1660 ++++++ .../docs/apis/FakeClassnameTags123Api.md | 104 + .../net4.7/FormModels/docs/apis/PetApi.md | 860 +++ .../net4.7/FormModels/docs/apis/StoreApi.md | 373 ++ .../net4.7/FormModels/docs/apis/UserApi.md | 715 +++ .../net4.7/FormModels/docs/models/Activity.md | 11 + .../ActivityOutputElementRepresentation.md | 11 + .../docs/models/AdditionalPropertiesClass.md | 17 + .../net4.7/FormModels/docs/models/Animal.md | 11 + .../FormModels/docs/models/ApiResponse.md | 12 + .../net4.7/FormModels/docs/models/Apple.md | 12 + .../net4.7/FormModels/docs/models/AppleReq.md | 11 + .../docs/models/ArrayOfArrayOfNumberOnly.md | 10 + .../docs/models/ArrayOfNumberOnly.md | 10 + .../FormModels/docs/models/ArrayTest.md | 12 + .../net4.7/FormModels/docs/models/Banana.md | 10 + .../FormModels/docs/models/BananaReq.md | 11 + .../FormModels/docs/models/BasquePig.md | 10 + .../FormModels/docs/models/Capitalization.md | 15 + .../net4.7/FormModels/docs/models/Cat.md | 12 + .../net4.7/FormModels/docs/models/Category.md | 11 + .../net4.7/FormModels/docs/models/ChildCat.md | 11 + .../docs/models/ChildCatAllOfPetType.md | 9 + .../FormModels/docs/models/ClassModel.md | 11 + .../docs/models/ComplexQuadrilateral.md | 11 + .../FormModels/docs/models/DanishPig.md | 10 + .../FormModels/docs/models/DateOnlyClass.md | 10 + .../docs/models/DeprecatedObject.md | 10 + .../net4.7/FormModels/docs/models/Dog.md | 12 + .../net4.7/FormModels/docs/models/Drawing.md | 13 + .../FormModels/docs/models/EnumArrays.md | 11 + .../docs/models/EnumArraysArrayEnumInner.md | 9 + .../docs/models/EnumArraysJustSymbol.md | 9 + .../FormModels/docs/models/EnumClass.md | 9 + .../net4.7/FormModels/docs/models/EnumTest.md | 18 + .../docs/models/EnumTestEnumInteger.md | 9 + .../docs/models/EnumTestEnumIntegerOnly.md | 9 + .../docs/models/EnumTestEnumString.md | 9 + .../docs/models/EquilateralTriangle.md | 11 + .../net4.7/FormModels/docs/models/File.md | 11 + .../docs/models/FileSchemaTestClass.md | 11 + .../FindPetsByStatusStatusParameterInner.md | 9 + .../net4.7/FormModels/docs/models/Foo.md | 10 + .../docs/models/FooGetDefaultResponse.md | 10 + .../FormModels/docs/models/FormatTest.md | 28 + .../net4.7/FormModels/docs/models/Fruit.md | 10 + .../net4.7/FormModels/docs/models/FruitReq.md | 9 + .../net4.7/FormModels/docs/models/GmFruit.md | 10 + .../docs/models/GrandparentAnimal.md | 10 + .../FormModels/docs/models/HasOnlyReadOnly.md | 11 + .../docs/models/HealthCheckResult.md | 11 + .../docs/models/IsoscelesTriangle.md | 11 + .../net4.7/FormModels/docs/models/List.md | 10 + .../docs/models/LiteralStringClass.md | 11 + .../net4.7/FormModels/docs/models/Mammal.md | 10 + .../net4.7/FormModels/docs/models/MapTest.md | 13 + .../models/MapTestMapOfEnumStringValue.md | 9 + .../net4.7/FormModels/docs/models/MixLog.md | 41 + ...dPropertiesAndAdditionalPropertiesClass.md | 13 + .../docs/models/Model200Response.md | 12 + .../FormModels/docs/models/ModelClient.md | 10 + .../net4.7/FormModels/docs/models/Name.md | 14 + ...cationtestGetElementsV1ResponseMPayload.md | 11 + .../FormModels/docs/models/NullableClass.md | 21 + .../docs/models/NullableGuidClass.md | 10 + .../FormModels/docs/models/NullableShape.md | 11 + .../FormModels/docs/models/NumberOnly.md | 10 + .../docs/models/ObjectWithDeprecatedFields.md | 13 + .../FormModels/docs/models/OneOfString.md | 9 + .../net4.7/FormModels/docs/models/Order.md | 15 + .../FormModels/docs/models/OrderStatus.md | 10 + .../FormModels/docs/models/OuterComposite.md | 12 + .../FormModels/docs/models/OuterEnum.md | 9 + .../docs/models/OuterEnumDefaultValue.md | 9 + .../docs/models/OuterEnumInteger.md | 9 + .../models/OuterEnumIntegerDefaultValue.md | 9 + .../FormModels/docs/models/OuterEnumTest.md | 9 + .../FormModels/docs/models/ParentPet.md | 10 + .../net4.7/FormModels/docs/models/Pet.md | 15 + .../FormModels/docs/models/PetStatus.md | 10 + .../net4.7/FormModels/docs/models/Pig.md | 10 + .../docs/models/PolymorphicProperty.md | 9 + .../FormModels/docs/models/Quadrilateral.md | 10 + .../docs/models/QuadrilateralInterface.md | 10 + .../FormModels/docs/models/ReadOnlyFirst.md | 11 + .../FormModels/docs/models/RequiredClass.md | 53 + ...iredClassRequiredNotnullableEnumInteger.md | 9 + ...ClassRequiredNotnullableEnumIntegerOnly.md | 9 + ...uiredClassRequiredNotnullableEnumString.md | 9 + ...equiredClassRequiredNullableEnumInteger.md | 9 + ...redClassRequiredNullableEnumIntegerOnly.md | 9 + ...RequiredClassRequiredNullableEnumString.md | 9 + .../net4.7/FormModels/docs/models/Return.md | 14 + .../docs/models/RolesReportsHash.md | 12 + .../docs/models/RolesReportsHashRole.md | 10 + .../FormModels/docs/models/ScaleneTriangle.md | 11 + .../net4.7/FormModels/docs/models/Shape.md | 10 + .../FormModels/docs/models/ShapeInterface.md | 10 + .../FormModels/docs/models/ShapeOrNull.md | 11 + .../docs/models/SimpleQuadrilateral.md | 11 + .../docs/models/SpecialModelName.md | 11 + .../net4.7/FormModels/docs/models/Tag.md | 11 + .../TestCollectionEndingWithWordList.md | 10 + .../TestCollectionEndingWithWordListObject.md | 10 + ...EnumParametersEnumHeaderStringParameter.md | 9 + ...tEnumParametersEnumQueryDoubleParameter.md | 9 + ...EnumParametersEnumQueryIntegerParameter.md | 9 + ...TestEnumParametersRequestEnumFormString.md | 10 + ...rametersRequestEnumFormStringArrayInner.md | 9 + ...lineFreeformAdditionalPropertiesRequest.md | 10 + .../net4.7/FormModels/docs/models/Triangle.md | 10 + .../docs/models/TriangleInterface.md | 10 + .../net4.7/FormModels/docs/models/User.md | 21 + .../net4.7/FormModels/docs/models/Whale.md | 12 + .../net4.7/FormModels/docs/models/Zebra.md | 11 + .../FormModels/docs/models/ZebraType.md | 9 + .../FormModels/docs/models/ZeroBasedEnum.md | 9 + .../docs/models/ZeroBasedEnumClass.md | 10 + .../models/ZeroBasedEnumClassZeroBasedEnum.md | 9 + .../FormModels/docs/scripts/git_push.ps1 | 75 + .../FormModels/docs/scripts/git_push.sh | 49 + .../Api/AnotherFakeApiTests.cs | 65 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 81 + .../Api/DefaultApiTests.cs | 107 + .../Api/DependencyInjectionTests.cs | 243 + .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 281 + .../Api/FakeClassnameTags123ApiTests.cs | 65 + .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 160 + .../Api/StoreApiTests.cs | 98 + .../Org.OpenAPITools.Test/Api/UserApiTests.cs | 138 + ...ctivityOutputElementRepresentationTests.cs | 74 + .../Model/ActivityTests.cs | 65 + .../Model/AdditionalPropertiesClassTests.cs | 128 + .../Model/AnimalTests.cs | 94 + .../Model/ApiResponseTests.cs | 83 + .../Model/AppleReqTests.cs | 74 + .../Org.OpenAPITools.Test/Model/AppleTests.cs | 83 + .../Model/ArrayOfArrayOfNumberOnlyTests.cs | 65 + .../Model/ArrayOfNumberOnlyTests.cs | 65 + .../Model/ArrayTestTests.cs | 83 + .../Model/BananaReqTests.cs | 74 + .../Model/BananaTests.cs | 65 + .../Model/BasquePigTests.cs | 65 + .../Model/CapitalizationTests.cs | 110 + .../Org.OpenAPITools.Test/Model/CatTests.cs | 65 + .../Model/CategoryTests.cs | 74 + .../Model/ChildCatAllOfPetTypeTests.cs | 56 + .../Model/ChildCatTests.cs | 74 + .../Model/ClassModelTests.cs | 65 + .../Model/ComplexQuadrilateralTests.cs | 74 + .../Model/DanishPigTests.cs | 65 + .../Model/DateOnlyClassTests.cs | 65 + .../Model/DeprecatedObjectTests.cs | 65 + .../Org.OpenAPITools.Test/Model/DogTests.cs | 65 + .../Model/DrawingTests.cs | 92 + .../Model/EnumArraysArrayEnumInnerTests.cs | 56 + .../Model/EnumArraysJustSymbolTests.cs | 56 + .../Model/EnumArraysTests.cs | 74 + .../Model/EnumClassTests.cs | 56 + .../Model/EnumTestEnumIntegerOnlyTests.cs | 56 + .../Model/EnumTestEnumIntegerTests.cs | 56 + .../Model/EnumTestEnumStringTests.cs | 56 + .../Model/EnumTestTests.cs | 137 + .../Model/EquilateralTriangleTests.cs | 74 + .../Model/FileSchemaTestClassTests.cs | 74 + .../Org.OpenAPITools.Test/Model/FileTests.cs | 65 + ...ndPetsByStatusStatusParameterInnerTests.cs | 56 + .../Model/FooGetDefaultResponseTests.cs | 65 + .../Org.OpenAPITools.Test/Model/FooTests.cs | 65 + .../Model/FormatTestTests.cs | 227 + .../Model/FruitReqTests.cs | 56 + .../Org.OpenAPITools.Test/Model/FruitTests.cs | 65 + .../Model/GmFruitTests.cs | 65 + .../Model/GrandparentAnimalTests.cs | 85 + .../Model/HasOnlyReadOnlyTests.cs | 74 + .../Model/HealthCheckResultTests.cs | 65 + .../Model/IsoscelesTriangleTests.cs | 74 + .../Org.OpenAPITools.Test/Model/ListTests.cs | 65 + .../Model/LiteralStringClassTests.cs | 74 + .../Model/MammalTests.cs | 65 + .../Model/MapTestMapOfEnumStringValueTests.cs | 56 + .../Model/MapTestTests.cs | 92 + .../Model/MixLogTests.cs | 344 ++ ...ertiesAndAdditionalPropertiesClassTests.cs | 92 + .../Model/Model200ResponseTests.cs | 74 + .../Model/ModelClientTests.cs | 65 + .../Org.OpenAPITools.Test/Model/NameTests.cs | 92 + ...ntestGetElementsV1ResponseMPayloadTests.cs | 74 + .../Model/NullableClassTests.cs | 164 + .../Model/NullableGuidClassTests.cs | 65 + .../Model/NullableShapeTests.cs | 65 + .../Model/NumberOnlyTests.cs | 65 + .../Model/ObjectWithDeprecatedFieldsTests.cs | 92 + .../Model/OneOfStringTests.cs | 56 + .../Model/OrderStatusTests.cs | 56 + .../Org.OpenAPITools.Test/Model/OrderTests.cs | 110 + .../Model/OuterCompositeTests.cs | 83 + .../Model/OuterEnumDefaultValueTests.cs | 56 + .../OuterEnumIntegerDefaultValueTests.cs | 56 + .../Model/OuterEnumIntegerTests.cs | 56 + .../Model/OuterEnumTestTests.cs | 56 + .../Model/OuterEnumTests.cs | 56 + .../Model/ParentPetTests.cs | 66 + .../Model/PetStatusTests.cs | 56 + .../Org.OpenAPITools.Test/Model/PetTests.cs | 110 + .../Org.OpenAPITools.Test/Model/PigTests.cs | 65 + .../Model/PolymorphicPropertyTests.cs | 56 + .../Model/QuadrilateralInterfaceTests.cs | 65 + .../Model/QuadrilateralTests.cs | 65 + .../Model/ReadOnlyFirstTests.cs | 74 + ...RequiredNotnullableEnumIntegerOnlyTests.cs | 56 + ...lassRequiredNotnullableEnumIntegerTests.cs | 56 + ...ClassRequiredNotnullableEnumStringTests.cs | 56 + ...assRequiredNullableEnumIntegerOnlyTests.cs | 56 + ...edClassRequiredNullableEnumIntegerTests.cs | 56 + ...redClassRequiredNullableEnumStringTests.cs | 56 + .../Model/RequiredClassTests.cs | 452 ++ .../Model/ReturnTests.cs | 92 + .../Model/RolesReportsHashRoleTests.cs | 65 + .../Model/RolesReportsHashTests.cs | 74 + .../Model/ScaleneTriangleTests.cs | 74 + .../Model/ShapeInterfaceTests.cs | 65 + .../Model/ShapeOrNullTests.cs | 65 + .../Org.OpenAPITools.Test/Model/ShapeTests.cs | 65 + .../Model/SimpleQuadrilateralTests.cs | 74 + .../Model/SpecialModelNameTests.cs | 74 + .../Org.OpenAPITools.Test/Model/TagTests.cs | 74 + ...CollectionEndingWithWordListObjectTests.cs | 65 + .../TestCollectionEndingWithWordListTests.cs | 65 + ...arametersEnumHeaderStringParameterTests.cs | 56 + ...ParametersEnumQueryDoubleParameterTests.cs | 56 + ...arametersEnumQueryIntegerParameterTests.cs | 56 + ...ersRequestEnumFormStringArrayInnerTests.cs | 56 + ...numParametersRequestEnumFormStringTests.cs | 56 + ...reeformAdditionalPropertiesRequestTests.cs | 65 + .../Model/TriangleInterfaceTests.cs | 65 + .../Model/TriangleTests.cs | 65 + .../Org.OpenAPITools.Test/Model/UserTests.cs | 164 + .../Org.OpenAPITools.Test/Model/WhaleTests.cs | 83 + .../Org.OpenAPITools.Test/Model/ZebraTests.cs | 74 + .../Model/ZebraTypeTests.cs | 56 + .../Model/ZeroBasedEnumClassTests.cs | 65 + .../ZeroBasedEnumClassZeroBasedEnumTests.cs | 56 + .../Model/ZeroBasedEnumTests.cs | 56 + .../Org.OpenAPITools.Test.csproj | 19 + .../src/Org.OpenAPITools.Test/README.md | 0 .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 402 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 1352 +++++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 5181 ++++++++++++++++ .../Api/FakeClassnameTags123Api.cs | 415 ++ .../src/Org.OpenAPITools/Api/IApi.cs | 15 + .../src/Org.OpenAPITools/Api/PetApi.cs | 2784 +++++++++ .../src/Org.OpenAPITools/Api/StoreApi.cs | 1197 ++++ .../src/Org.OpenAPITools/Api/UserApi.cs | 2223 +++++++ .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Org.OpenAPITools/Client/ApiKeyToken.cs | 52 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 210 + .../src/Org.OpenAPITools/Client/BasicToken.cs | 42 + .../Org.OpenAPITools/Client/BearerToken.cs | 37 + .../Org.OpenAPITools/Client/ClientUtils.cs | 423 ++ .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 290 + .../Client/HttpSigningConfiguration.cs | 641 ++ .../Client/HttpSigningToken.cs | 41 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/OAuthToken.cs | 37 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 72 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 41 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 61 + .../src/Org.OpenAPITools/Model/Activity.cs | 178 + .../ActivityOutputElementRepresentation.cs | 207 + .../Model/AdditionalPropertiesClass.cs | 400 ++ .../src/Org.OpenAPITools/Model/Animal.cs | 221 + .../src/Org.OpenAPITools/Model/ApiResponse.cs | 230 + .../src/Org.OpenAPITools/Model/Apple.cs | 262 + .../src/Org.OpenAPITools/Model/AppleReq.cs | 189 + .../Model/ArrayOfArrayOfNumberOnly.cs | 178 + .../Model/ArrayOfNumberOnly.cs | 178 + .../src/Org.OpenAPITools/Model/ArrayTest.cs | 242 + .../src/Org.OpenAPITools/Model/Banana.cs | 172 + .../src/Org.OpenAPITools/Model/BananaReq.cs | 187 + .../src/Org.OpenAPITools/Model/BasquePig.cs | 169 + .../Org.OpenAPITools/Model/Capitalization.cs | 320 + .../src/Org.OpenAPITools/Model/Cat.cs | 189 + .../src/Org.OpenAPITools/Model/Category.cs | 196 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 179 + .../Model/ChildCatAllOfPetType.cs | 160 + .../src/Org.OpenAPITools/Model/ClassModel.cs | 174 + .../Model/ComplexQuadrilateral.cs | 193 + .../src/Org.OpenAPITools/Model/DanishPig.cs | 169 + .../Org.OpenAPITools/Model/DateOnlyClass.cs | 178 + .../Model/DeprecatedObject.cs | 174 + .../src/Org.OpenAPITools/Model/Dog.cs | 191 + .../src/Org.OpenAPITools/Model/Drawing.cs | 268 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 208 + .../Model/EnumArraysArrayEnumInner.cs | 174 + .../Model/EnumArraysJustSymbol.cs | 174 + .../src/Org.OpenAPITools/Model/EnumClass.cs | 188 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 410 ++ .../Model/EnumTestEnumInteger.cs | 168 + .../Model/EnumTestEnumIntegerOnly.cs | 168 + .../Model/EnumTestEnumString.cs | 258 + .../Model/EquilateralTriangle.cs | 193 + .../src/Org.OpenAPITools/Model/File.cs | 175 + .../Model/FileSchemaTestClass.cs | 210 + .../FindPetsByStatusStatusParameterInner.cs | 188 + .../src/Org.OpenAPITools/Model/Foo.cs | 174 + .../Model/FooGetDefaultResponse.cs | 178 + .../src/Org.OpenAPITools/Model/FormatTest.cs | 798 +++ .../src/Org.OpenAPITools/Model/Fruit.cs | 218 + .../src/Org.OpenAPITools/Model/FruitReq.cs | 188 + .../src/Org.OpenAPITools/Model/GmFruit.cs | 235 + .../Model/GrandparentAnimal.cs | 192 + .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 244 + .../Model/HealthCheckResult.cs | 171 + .../Model/IsoscelesTriangle.cs | 186 + .../src/Org.OpenAPITools/Model/List.cs | 174 + .../Model/LiteralStringClass.cs | 203 + .../src/Org.OpenAPITools/Model/Mammal.cs | 266 + .../src/Org.OpenAPITools/Model/MapTest.cs | 274 + .../Model/MapTestMapOfEnumStringValue.cs | 174 + .../src/Org.OpenAPITools/Model/MixLog.cs | 1027 ++++ ...dPropertiesAndAdditionalPropertiesClass.cs | 270 + .../Model/Model200Response.cs | 201 + .../src/Org.OpenAPITools/Model/ModelClient.cs | 174 + .../src/Org.OpenAPITools/Model/Name.cs | 291 + ...cationtestGetElementsV1ResponseMPayload.cs | 192 + .../Org.OpenAPITools/Model/NullableClass.cs | 496 ++ .../Model/NullableGuidClass.cs | 173 + .../Org.OpenAPITools/Model/NullableShape.cs | 237 + .../src/Org.OpenAPITools/Model/NumberOnly.cs | 172 + .../Model/ObjectWithDeprecatedFields.cs | 268 + .../src/Org.OpenAPITools/Model/OneOfString.cs | 157 + .../src/Org.OpenAPITools/Model/Order.cs | 317 + .../src/Org.OpenAPITools/Model/OrderStatus.cs | 189 + .../Org.OpenAPITools/Model/OuterComposite.cs | 228 + .../src/Org.OpenAPITools/Model/OuterEnum.cs | 188 + .../Model/OuterEnumDefaultValue.cs | 188 + .../Model/OuterEnumInteger.cs | 179 + .../Model/OuterEnumIntegerDefaultValue.cs | 179 + .../Org.OpenAPITools/Model/OuterEnumTest.cs | 258 + .../src/Org.OpenAPITools/Model/ParentPet.cs | 158 + .../src/Org.OpenAPITools/Model/Pet.cs | 317 + .../src/Org.OpenAPITools/Model/PetStatus.cs | 189 + .../src/Org.OpenAPITools/Model/Pig.cs | 237 + .../Model/PolymorphicProperty.cs | 239 + .../Org.OpenAPITools/Model/Quadrilateral.cs | 237 + .../Model/QuadrilateralInterface.cs | 169 + .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 241 + .../Org.OpenAPITools/Model/RequiredClass.cs | 1335 +++++ ...iredClassRequiredNotnullableEnumInteger.cs | 168 + ...ClassRequiredNotnullableEnumIntegerOnly.cs | 168 + ...uiredClassRequiredNotnullableEnumString.cs | 258 + ...equiredClassRequiredNullableEnumInteger.cs | 168 + ...redClassRequiredNullableEnumIntegerOnly.cs | 168 + ...RequiredClassRequiredNullableEnumString.cs | 258 + .../src/Org.OpenAPITools/Model/Return.cs | 246 + .../Model/RolesReportsHash.cs | 204 + .../Model/RolesReportsHashRole.cs | 174 + .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 193 + .../src/Org.OpenAPITools/Model/Shape.cs | 237 + .../Org.OpenAPITools/Model/ShapeInterface.cs | 169 + .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 237 + .../Model/SimpleQuadrilateral.cs | 193 + .../Model/SpecialModelName.cs | 201 + .../src/Org.OpenAPITools/Model/Tag.cs | 201 + .../Model/TestCollectionEndingWithWordList.cs | 174 + .../TestCollectionEndingWithWordListObject.cs | 178 + ...EnumParametersEnumHeaderStringParameter.cs | 188 + ...tEnumParametersEnumQueryDoubleParameter.cs | 168 + ...EnumParametersEnumQueryIntegerParameter.cs | 168 + ...TestEnumParametersRequestEnumFormString.cs | 189 + ...rametersRequestEnumFormStringArrayInner.cs | 174 + ...lineFreeformAdditionalPropertiesRequest.cs | 174 + .../src/Org.OpenAPITools/Model/Triangle.cs | 266 + .../Model/TriangleInterface.cs | 169 + .../src/Org.OpenAPITools/Model/User.cs | 497 ++ .../src/Org.OpenAPITools/Model/Whale.cs | 223 + .../src/Org.OpenAPITools/Model/Zebra.cs | 200 + .../src/Org.OpenAPITools/Model/ZebraType.cs | 188 + .../Org.OpenAPITools/Model/ZeroBasedEnum.cs | 174 + .../Model/ZeroBasedEnumClass.cs | 176 + .../Model/ZeroBasedEnumClassZeroBasedEnum.cs | 174 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 33 + .../FormModels/src/Org.OpenAPITools/README.md | 223 + .../generichost/net4.7/OneOf/.gitignore | 362 ++ .../net4.7/OneOf/.openapi-generator-ignore | 23 + .../net4.7/OneOf/.openapi-generator/FILES | 40 + .../net4.7/OneOf/.openapi-generator/VERSION | 1 + .../net4.7/OneOf/Org.OpenAPITools.sln | 27 + .../csharp/generichost/net4.7/OneOf/README.md | 1 + .../generichost/net4.7/OneOf/api/openapi.yaml | 41 + .../generichost/net4.7/OneOf/appveyor.yml | 9 + .../net4.7/OneOf/docs/apis/DefaultApi.md | 90 + .../net4.7/OneOf/docs/models/Apple.md | 10 + .../net4.7/OneOf/docs/models/Banana.md | 10 + .../net4.7/OneOf/docs/models/Fruit.md | 10 + .../net4.7/OneOf/docs/scripts/git_push.ps1 | 75 + .../net4.7/OneOf/docs/scripts/git_push.sh | 49 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 58 + .../Api/DefaultApiTests.cs | 64 + .../Api/DependencyInjectionTests.cs | 103 + .../Org.OpenAPITools.Test/Model/AppleTests.cs | 65 + .../Model/BananaTests.cs | 65 + .../Org.OpenAPITools.Test/Model/FruitTests.cs | 65 + .../Org.OpenAPITools.Test.csproj | 19 + .../OneOf/src/Org.OpenAPITools.Test/README.md | 0 .../src/Org.OpenAPITools/Api/DefaultApi.cs | 329 ++ .../OneOf/src/Org.OpenAPITools/Api/IApi.cs | 15 + .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 170 + .../Org.OpenAPITools/Client/ClientUtils.cs | 329 ++ .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 131 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 55 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 57 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 71 + .../OneOf/src/Org.OpenAPITools/Model/Apple.cs | 174 + .../src/Org.OpenAPITools/Model/Banana.cs | 172 + .../OneOf/src/Org.OpenAPITools/Model/Fruit.cs | 225 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 33 + .../OneOf/src/Org.OpenAPITools/README.md | 177 + .../generichost/net4.7/Petstore/.gitignore | 362 ++ .../net4.7/Petstore/.openapi-generator-ignore | 23 + .../net4.7/Petstore/.openapi-generator/FILES | 234 + .../Petstore/.openapi-generator/VERSION | 1 + .../net4.7/Petstore/Org.OpenAPITools.sln | 27 + .../generichost/net4.7/Petstore/README.md | 1 + .../net4.7/Petstore/api/openapi.yaml | 3004 ++++++++++ .../generichost/net4.7/Petstore/appveyor.yml | 9 + .../Petstore/docs/apis/AnotherFakeApi.md | 99 + .../net4.7/Petstore/docs/apis/DefaultApi.md | 429 ++ .../net4.7/Petstore/docs/apis/FakeApi.md | 1660 ++++++ .../docs/apis/FakeClassnameTags123Api.md | 104 + .../net4.7/Petstore/docs/apis/PetApi.md | 860 +++ .../net4.7/Petstore/docs/apis/StoreApi.md | 373 ++ .../net4.7/Petstore/docs/apis/UserApi.md | 715 +++ .../net4.7/Petstore/docs/models/Activity.md | 11 + .../ActivityOutputElementRepresentation.md | 11 + .../docs/models/AdditionalPropertiesClass.md | 17 + .../net4.7/Petstore/docs/models/Animal.md | 11 + .../Petstore/docs/models/ApiResponse.md | 12 + .../net4.7/Petstore/docs/models/Apple.md | 12 + .../net4.7/Petstore/docs/models/AppleReq.md | 11 + .../docs/models/ArrayOfArrayOfNumberOnly.md | 10 + .../Petstore/docs/models/ArrayOfNumberOnly.md | 10 + .../net4.7/Petstore/docs/models/ArrayTest.md | 12 + .../net4.7/Petstore/docs/models/Banana.md | 10 + .../net4.7/Petstore/docs/models/BananaReq.md | 11 + .../net4.7/Petstore/docs/models/BasquePig.md | 10 + .../Petstore/docs/models/Capitalization.md | 15 + .../net4.7/Petstore/docs/models/Cat.md | 12 + .../net4.7/Petstore/docs/models/Category.md | 11 + .../net4.7/Petstore/docs/models/ChildCat.md | 11 + .../net4.7/Petstore/docs/models/ClassModel.md | 11 + .../docs/models/ComplexQuadrilateral.md | 11 + .../net4.7/Petstore/docs/models/DanishPig.md | 10 + .../Petstore/docs/models/DateOnlyClass.md | 10 + .../Petstore/docs/models/DeprecatedObject.md | 10 + .../net4.7/Petstore/docs/models/Dog.md | 12 + .../net4.7/Petstore/docs/models/Drawing.md | 13 + .../net4.7/Petstore/docs/models/EnumArrays.md | 11 + .../net4.7/Petstore/docs/models/EnumClass.md | 9 + .../net4.7/Petstore/docs/models/EnumTest.md | 18 + .../docs/models/EquilateralTriangle.md | 11 + .../net4.7/Petstore/docs/models/File.md | 11 + .../docs/models/FileSchemaTestClass.md | 11 + .../net4.7/Petstore/docs/models/Foo.md | 10 + .../docs/models/FooGetDefaultResponse.md | 10 + .../net4.7/Petstore/docs/models/FormatTest.md | 28 + .../net4.7/Petstore/docs/models/Fruit.md | 10 + .../net4.7/Petstore/docs/models/FruitReq.md | 9 + .../net4.7/Petstore/docs/models/GmFruit.md | 10 + .../Petstore/docs/models/GrandparentAnimal.md | 10 + .../Petstore/docs/models/HasOnlyReadOnly.md | 11 + .../Petstore/docs/models/HealthCheckResult.md | 11 + .../Petstore/docs/models/IsoscelesTriangle.md | 11 + .../net4.7/Petstore/docs/models/List.md | 10 + .../docs/models/LiteralStringClass.md | 11 + .../net4.7/Petstore/docs/models/Mammal.md | 10 + .../net4.7/Petstore/docs/models/MapTest.md | 13 + .../net4.7/Petstore/docs/models/MixLog.md | 41 + ...dPropertiesAndAdditionalPropertiesClass.md | 13 + .../Petstore/docs/models/Model200Response.md | 12 + .../Petstore/docs/models/ModelClient.md | 10 + .../net4.7/Petstore/docs/models/Name.md | 14 + ...cationtestGetElementsV1ResponseMPayload.md | 11 + .../Petstore/docs/models/NullableClass.md | 21 + .../Petstore/docs/models/NullableGuidClass.md | 10 + .../Petstore/docs/models/NullableShape.md | 11 + .../net4.7/Petstore/docs/models/NumberOnly.md | 10 + .../docs/models/ObjectWithDeprecatedFields.md | 13 + .../Petstore/docs/models/OneOfString.md | 9 + .../net4.7/Petstore/docs/models/Order.md | 15 + .../Petstore/docs/models/OuterComposite.md | 12 + .../net4.7/Petstore/docs/models/OuterEnum.md | 9 + .../docs/models/OuterEnumDefaultValue.md | 9 + .../Petstore/docs/models/OuterEnumInteger.md | 9 + .../models/OuterEnumIntegerDefaultValue.md | 9 + .../Petstore/docs/models/OuterEnumTest.md | 9 + .../net4.7/Petstore/docs/models/ParentPet.md | 10 + .../net4.7/Petstore/docs/models/Pet.md | 15 + .../net4.7/Petstore/docs/models/Pig.md | 10 + .../docs/models/PolymorphicProperty.md | 9 + .../Petstore/docs/models/Quadrilateral.md | 10 + .../docs/models/QuadrilateralInterface.md | 10 + .../Petstore/docs/models/ReadOnlyFirst.md | 11 + .../Petstore/docs/models/RequiredClass.md | 53 + .../net4.7/Petstore/docs/models/Return.md | 14 + .../Petstore/docs/models/RolesReportsHash.md | 12 + .../docs/models/RolesReportsHashRole.md | 10 + .../Petstore/docs/models/ScaleneTriangle.md | 11 + .../net4.7/Petstore/docs/models/Shape.md | 10 + .../Petstore/docs/models/ShapeInterface.md | 10 + .../Petstore/docs/models/ShapeOrNull.md | 11 + .../docs/models/SimpleQuadrilateral.md | 11 + .../Petstore/docs/models/SpecialModelName.md | 11 + .../net4.7/Petstore/docs/models/Tag.md | 11 + .../TestCollectionEndingWithWordList.md | 10 + .../TestCollectionEndingWithWordListObject.md | 10 + ...lineFreeformAdditionalPropertiesRequest.md | 10 + .../net4.7/Petstore/docs/models/Triangle.md | 10 + .../Petstore/docs/models/TriangleInterface.md | 10 + .../net4.7/Petstore/docs/models/User.md | 21 + .../net4.7/Petstore/docs/models/Whale.md | 12 + .../net4.7/Petstore/docs/models/Zebra.md | 11 + .../Petstore/docs/models/ZeroBasedEnum.md | 9 + .../docs/models/ZeroBasedEnumClass.md | 10 + .../net4.7/Petstore/docs/scripts/git_push.ps1 | 75 + .../net4.7/Petstore/docs/scripts/git_push.sh | 49 + .../Api/AnotherFakeApiTests.cs | 65 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 81 + .../Api/DefaultApiTests.cs | 107 + .../Api/DependencyInjectionTests.cs | 243 + .../Org.OpenAPITools.Test/Api/FakeApiTests.cs | 281 + .../Api/FakeClassnameTags123ApiTests.cs | 65 + .../Org.OpenAPITools.Test/Api/PetApiTests.cs | 160 + .../Api/StoreApiTests.cs | 98 + .../Org.OpenAPITools.Test/Api/UserApiTests.cs | 138 + ...ctivityOutputElementRepresentationTests.cs | 74 + .../Model/ActivityTests.cs | 65 + .../Model/AdditionalPropertiesClassTests.cs | 128 + .../Model/AnimalTests.cs | 94 + .../Model/ApiResponseTests.cs | 83 + .../Model/AppleReqTests.cs | 74 + .../Org.OpenAPITools.Test/Model/AppleTests.cs | 83 + .../Model/ArrayOfArrayOfNumberOnlyTests.cs | 65 + .../Model/ArrayOfNumberOnlyTests.cs | 65 + .../Model/ArrayTestTests.cs | 83 + .../Model/BananaReqTests.cs | 74 + .../Model/BananaTests.cs | 65 + .../Model/BasquePigTests.cs | 65 + .../Model/CapitalizationTests.cs | 110 + .../Org.OpenAPITools.Test/Model/CatTests.cs | 65 + .../Model/CategoryTests.cs | 74 + .../Model/ChildCatTests.cs | 74 + .../Model/ClassModelTests.cs | 65 + .../Model/ComplexQuadrilateralTests.cs | 74 + .../Model/DanishPigTests.cs | 65 + .../Model/DateOnlyClassTests.cs | 65 + .../Model/DeprecatedObjectTests.cs | 65 + .../Org.OpenAPITools.Test/Model/DogTests.cs | 65 + .../Model/DrawingTests.cs | 92 + .../Model/EnumArraysTests.cs | 74 + .../Model/EnumClassTests.cs | 56 + .../Model/EnumTestTests.cs | 137 + .../Model/EquilateralTriangleTests.cs | 74 + .../Model/FileSchemaTestClassTests.cs | 74 + .../Org.OpenAPITools.Test/Model/FileTests.cs | 65 + .../Model/FooGetDefaultResponseTests.cs | 65 + .../Org.OpenAPITools.Test/Model/FooTests.cs | 65 + .../Model/FormatTestTests.cs | 227 + .../Model/FruitReqTests.cs | 56 + .../Org.OpenAPITools.Test/Model/FruitTests.cs | 65 + .../Model/GmFruitTests.cs | 65 + .../Model/GrandparentAnimalTests.cs | 85 + .../Model/HasOnlyReadOnlyTests.cs | 74 + .../Model/HealthCheckResultTests.cs | 65 + .../Model/IsoscelesTriangleTests.cs | 74 + .../Org.OpenAPITools.Test/Model/ListTests.cs | 65 + .../Model/LiteralStringClassTests.cs | 74 + .../Model/MammalTests.cs | 65 + .../Model/MapTestTests.cs | 92 + .../Model/MixLogTests.cs | 344 ++ ...ertiesAndAdditionalPropertiesClassTests.cs | 92 + .../Model/Model200ResponseTests.cs | 74 + .../Model/ModelClientTests.cs | 65 + .../Org.OpenAPITools.Test/Model/NameTests.cs | 92 + ...ntestGetElementsV1ResponseMPayloadTests.cs | 74 + .../Model/NullableClassTests.cs | 164 + .../Model/NullableGuidClassTests.cs | 65 + .../Model/NullableShapeTests.cs | 65 + .../Model/NumberOnlyTests.cs | 65 + .../Model/ObjectWithDeprecatedFieldsTests.cs | 92 + .../Model/OneOfStringTests.cs | 56 + .../Org.OpenAPITools.Test/Model/OrderTests.cs | 110 + .../Model/OuterCompositeTests.cs | 83 + .../Model/OuterEnumDefaultValueTests.cs | 56 + .../OuterEnumIntegerDefaultValueTests.cs | 56 + .../Model/OuterEnumIntegerTests.cs | 56 + .../Model/OuterEnumTestTests.cs | 56 + .../Model/OuterEnumTests.cs | 56 + .../Model/ParentPetTests.cs | 66 + .../Org.OpenAPITools.Test/Model/PetTests.cs | 110 + .../Org.OpenAPITools.Test/Model/PigTests.cs | 65 + .../Model/PolymorphicPropertyTests.cs | 56 + .../Model/QuadrilateralInterfaceTests.cs | 65 + .../Model/QuadrilateralTests.cs | 65 + .../Model/ReadOnlyFirstTests.cs | 74 + .../Model/RequiredClassTests.cs | 452 ++ .../Model/ReturnTests.cs | 92 + .../Model/RolesReportsHashRoleTests.cs | 65 + .../Model/RolesReportsHashTests.cs | 74 + .../Model/ScaleneTriangleTests.cs | 74 + .../Model/ShapeInterfaceTests.cs | 65 + .../Model/ShapeOrNullTests.cs | 65 + .../Org.OpenAPITools.Test/Model/ShapeTests.cs | 65 + .../Model/SimpleQuadrilateralTests.cs | 74 + .../Model/SpecialModelNameTests.cs | 74 + .../Org.OpenAPITools.Test/Model/TagTests.cs | 74 + ...CollectionEndingWithWordListObjectTests.cs | 65 + .../TestCollectionEndingWithWordListTests.cs | 65 + ...reeformAdditionalPropertiesRequestTests.cs | 65 + .../Model/TriangleInterfaceTests.cs | 65 + .../Model/TriangleTests.cs | 65 + .../Org.OpenAPITools.Test/Model/UserTests.cs | 164 + .../Org.OpenAPITools.Test/Model/WhaleTests.cs | 83 + .../Org.OpenAPITools.Test/Model/ZebraTests.cs | 74 + .../Model/ZeroBasedEnumClassTests.cs | 65 + .../Model/ZeroBasedEnumTests.cs | 56 + .../Org.OpenAPITools.Test.csproj | 19 + .../src/Org.OpenAPITools.Test/README.md | 0 .../Org.OpenAPITools/Api/AnotherFakeApi.cs | 402 ++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 1352 +++++ .../src/Org.OpenAPITools/Api/FakeApi.cs | 5193 +++++++++++++++++ .../Api/FakeClassnameTags123Api.cs | 415 ++ .../Petstore/src/Org.OpenAPITools/Api/IApi.cs | 15 + .../src/Org.OpenAPITools/Api/PetApi.cs | 2784 +++++++++ .../src/Org.OpenAPITools/Api/StoreApi.cs | 1197 ++++ .../src/Org.OpenAPITools/Api/UserApi.cs | 2223 +++++++ .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Org.OpenAPITools/Client/ApiKeyToken.cs | 52 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 210 + .../src/Org.OpenAPITools/Client/BasicToken.cs | 42 + .../Org.OpenAPITools/Client/BearerToken.cs | 37 + .../Org.OpenAPITools/Client/ClientUtils.cs | 427 ++ .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 244 + .../Client/HttpSigningConfiguration.cs | 641 ++ .../Client/HttpSigningToken.cs | 41 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/OAuthToken.cs | 37 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 72 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 41 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 61 + .../src/Org.OpenAPITools/Model/Activity.cs | 178 + .../ActivityOutputElementRepresentation.cs | 207 + .../Model/AdditionalPropertiesClass.cs | 400 ++ .../src/Org.OpenAPITools/Model/Animal.cs | 221 + .../src/Org.OpenAPITools/Model/ApiResponse.cs | 230 + .../src/Org.OpenAPITools/Model/Apple.cs | 262 + .../src/Org.OpenAPITools/Model/AppleReq.cs | 189 + .../Model/ArrayOfArrayOfNumberOnly.cs | 178 + .../Model/ArrayOfNumberOnly.cs | 178 + .../src/Org.OpenAPITools/Model/ArrayTest.cs | 242 + .../src/Org.OpenAPITools/Model/Banana.cs | 172 + .../src/Org.OpenAPITools/Model/BananaReq.cs | 187 + .../src/Org.OpenAPITools/Model/BasquePig.cs | 169 + .../Org.OpenAPITools/Model/Capitalization.cs | 320 + .../src/Org.OpenAPITools/Model/Cat.cs | 189 + .../src/Org.OpenAPITools/Model/Category.cs | 196 + .../src/Org.OpenAPITools/Model/ChildCat.cs | 231 + .../src/Org.OpenAPITools/Model/ClassModel.cs | 174 + .../Model/ComplexQuadrilateral.cs | 193 + .../src/Org.OpenAPITools/Model/DanishPig.cs | 169 + .../Org.OpenAPITools/Model/DateOnlyClass.cs | 178 + .../Model/DeprecatedObject.cs | 174 + .../src/Org.OpenAPITools/Model/Dog.cs | 191 + .../src/Org.OpenAPITools/Model/Drawing.cs | 268 + .../src/Org.OpenAPITools/Model/EnumArrays.cs | 337 ++ .../src/Org.OpenAPITools/Model/EnumClass.cs | 188 + .../src/Org.OpenAPITools/Model/EnumTest.cs | 881 +++ .../Model/EquilateralTriangle.cs | 193 + .../src/Org.OpenAPITools/Model/File.cs | 175 + .../Model/FileSchemaTestClass.cs | 210 + .../src/Org.OpenAPITools/Model/Foo.cs | 174 + .../Model/FooGetDefaultResponse.cs | 178 + .../src/Org.OpenAPITools/Model/FormatTest.cs | 798 +++ .../src/Org.OpenAPITools/Model/Fruit.cs | 218 + .../src/Org.OpenAPITools/Model/FruitReq.cs | 188 + .../src/Org.OpenAPITools/Model/GmFruit.cs | 235 + .../Model/GrandparentAnimal.cs | 192 + .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 244 + .../Model/HealthCheckResult.cs | 171 + .../Model/IsoscelesTriangle.cs | 186 + .../src/Org.OpenAPITools/Model/List.cs | 174 + .../Model/LiteralStringClass.cs | 203 + .../src/Org.OpenAPITools/Model/Mammal.cs | 266 + .../src/Org.OpenAPITools/Model/MapTest.cs | 340 ++ .../src/Org.OpenAPITools/Model/MixLog.cs | 1027 ++++ ...dPropertiesAndAdditionalPropertiesClass.cs | 270 + .../Model/Model200Response.cs | 201 + .../src/Org.OpenAPITools/Model/ModelClient.cs | 174 + .../src/Org.OpenAPITools/Model/Name.cs | 291 + ...cationtestGetElementsV1ResponseMPayload.cs | 192 + .../Org.OpenAPITools/Model/NullableClass.cs | 496 ++ .../Model/NullableGuidClass.cs | 173 + .../Org.OpenAPITools/Model/NullableShape.cs | 237 + .../src/Org.OpenAPITools/Model/NumberOnly.cs | 172 + .../Model/ObjectWithDeprecatedFields.cs | 268 + .../src/Org.OpenAPITools/Model/OneOfString.cs | 157 + .../src/Org.OpenAPITools/Model/Order.cs | 396 ++ .../Org.OpenAPITools/Model/OuterComposite.cs | 228 + .../src/Org.OpenAPITools/Model/OuterEnum.cs | 188 + .../Model/OuterEnumDefaultValue.cs | 188 + .../Model/OuterEnumInteger.cs | 179 + .../Model/OuterEnumIntegerDefaultValue.cs | 179 + .../Org.OpenAPITools/Model/OuterEnumTest.cs | 258 + .../src/Org.OpenAPITools/Model/ParentPet.cs | 158 + .../src/Org.OpenAPITools/Model/Pet.cs | 396 ++ .../src/Org.OpenAPITools/Model/Pig.cs | 237 + .../Model/PolymorphicProperty.cs | 239 + .../Org.OpenAPITools/Model/Quadrilateral.cs | 237 + .../Model/QuadrilateralInterface.cs | 169 + .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 241 + .../Org.OpenAPITools/Model/RequiredClass.cs | 2378 ++++++++ .../src/Org.OpenAPITools/Model/Return.cs | 246 + .../Model/RolesReportsHash.cs | 204 + .../Model/RolesReportsHashRole.cs | 174 + .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 193 + .../src/Org.OpenAPITools/Model/Shape.cs | 237 + .../Org.OpenAPITools/Model/ShapeInterface.cs | 169 + .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 237 + .../Model/SimpleQuadrilateral.cs | 193 + .../Model/SpecialModelName.cs | 201 + .../src/Org.OpenAPITools/Model/Tag.cs | 201 + .../Model/TestCollectionEndingWithWordList.cs | 174 + .../TestCollectionEndingWithWordListObject.cs | 178 + ...lineFreeformAdditionalPropertiesRequest.cs | 174 + .../src/Org.OpenAPITools/Model/Triangle.cs | 266 + .../Model/TriangleInterface.cs | 169 + .../src/Org.OpenAPITools/Model/User.cs | 497 ++ .../src/Org.OpenAPITools/Model/Whale.cs | 223 + .../src/Org.OpenAPITools/Model/Zebra.cs | 277 + .../Org.OpenAPITools/Model/ZeroBasedEnum.cs | 174 + .../Model/ZeroBasedEnumClass.cs | 239 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 33 + .../Petstore/src/Org.OpenAPITools/README.md | 223 + .../net4.7/UseDateTimeForDate/.gitignore | 362 ++ .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 36 + .../.openapi-generator/VERSION | 1 + .../UseDateTimeForDate/Org.OpenAPITools.sln | 27 + .../net4.7/UseDateTimeForDate/README.md | 1 + .../UseDateTimeForDate/api/openapi.yaml | 35 + .../net4.7/UseDateTimeForDate/appveyor.yml | 9 + .../docs/apis/DefaultApi.md | 90 + .../docs/models/NowGet200Response.md | 11 + .../docs/scripts/git_push.ps1 | 75 + .../docs/scripts/git_push.sh | 49 + .../Org.OpenAPITools.Test/Api/ApiTestsBase.cs | 58 + .../Api/DefaultApiTests.cs | 64 + .../Api/DependencyInjectionTests.cs | 103 + .../Model/NowGet200ResponseTests.cs | 74 + .../Org.OpenAPITools.Test.csproj | 19 + .../src/Org.OpenAPITools.Test/README.md | 0 .../src/Org.OpenAPITools/Api/DefaultApi.cs | 329 ++ .../src/Org.OpenAPITools/Api/IApi.cs | 15 + .../Org.OpenAPITools/Client/ApiException.cs | 50 + .../src/Org.OpenAPITools/Client/ApiFactory.cs | 49 + .../Client/ApiResponseEventArgs.cs | 24 + .../Org.OpenAPITools/Client/ApiResponse`1.cs | 170 + .../Org.OpenAPITools/Client/ClientUtils.cs | 314 + .../Client/CookieContainer.cs | 18 + .../Client/DateTimeJsonConverter.cs | 77 + .../Client/DateTimeNullableJsonConverter.cs | 82 + .../Client/ExceptionEventArgs.cs | 24 + .../Client/HostConfiguration.cs | 129 + .../Client/JsonSerializerOptionsProvider.cs | 25 + .../src/Org.OpenAPITools/Client/Option.cs | 51 + .../Client/RateLimitProvider`1.cs | 55 + .../src/Org.OpenAPITools/Client/TokenBase.cs | 69 + .../Client/TokenContainer`1.cs | 35 + .../Client/TokenProvider`1.cs | 42 + .../Extensions/IHostBuilderExtensions.cs | 57 + .../IHttpClientBuilderExtensions.cs | 77 + .../IServiceCollectionExtensions.cs | 71 + .../Model/NowGet200Response.cs | 201 + .../Org.OpenAPITools/Org.OpenAPITools.csproj | 32 + .../src/Org.OpenAPITools/README.md | 176 + 991 files changed, 139920 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/samples-dotnet-net47.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-allOf.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-anyOf.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-anyOfNoCompare.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-formModels.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-oneOf.yaml create mode 100644 bin/configs/csharp-generichost-net4.7-useDateTimeForDate.yaml create mode 100644 bin/configs/csharp-generichost-net4.7.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Adult.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Child.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Person.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/AdultTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/ChildTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/PersonTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Apple.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Banana.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Fruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Apple.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Banana.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Fruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/AppleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/BananaTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/FruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/AnotherFakeApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeClassnameTags123Api.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/StoreApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/UserApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Activity.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ActivityOutputElementRepresentation.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AdditionalPropertiesClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Animal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ApiResponse.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Apple.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AppleReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfArrayOfNumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfNumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Banana.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BananaReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BasquePig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Capitalization.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Cat.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Category.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCat.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCatAllOfPetType.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ClassModel.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ComplexQuadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DanishPig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DeprecatedObject.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Dog.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Drawing.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArrays.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysArrayEnumInner.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysJustSymbol.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumInteger.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumIntegerOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EquilateralTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/File.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FileSchemaTestClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FindPetsByStatusStatusParameterInner.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Foo.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FooGetDefaultResponse.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Fruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FruitReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GmFruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GrandparentAnimal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HasOnlyReadOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HealthCheckResult.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/IsoscelesTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/List.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/LiteralStringClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Mammal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTestMapOfEnumStringValue.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixLog.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Model200Response.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ModelClient.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Name.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NotificationtestGetElementsV1ResponseMPayload.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableGuidClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableShape.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ObjectWithDeprecatedFields.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OneOfString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Order.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OrderStatus.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterComposite.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnum.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumDefaultValue.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumInteger.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumIntegerDefaultValue.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ParentPet.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pet.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PetStatus.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PolymorphicProperty.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Quadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/QuadrilateralInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ReadOnlyFirst.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumInteger.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumIntegerOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumInteger.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Return.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHash.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHashRole.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ScaleneTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Shape.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeOrNull.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SimpleQuadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SpecialModelName.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Tag.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordList.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordListObject.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumHeaderStringParameter.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryDoubleParameter.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryIntegerParameter.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Triangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TriangleInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/User.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Whale.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Zebra.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZebraType.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnum.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClassZeroBasedEnum.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/UserApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AnimalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CatTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CategoryTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatAllOfPetTypeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DogTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DrawingTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysArrayEnumInnerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysJustSymbolTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FindPetsByStatusStatusParameterInnerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ListTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MammalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestMapOfEnumStringValueTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixLogTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NameTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderStatusTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetStatusTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReturnTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TagTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumHeaderStringParameterTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryDoubleParameterTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryIntegerParameterTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringArrayInnerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/UserTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/WhaleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTypeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassZeroBasedEnumTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiKeyToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BasicToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BearerToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/OAuthToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumInteger.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumIntegerOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FindPetsByStatusStatusParameterInner.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixLog.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OrderStatus.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnum.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumInteger.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PetStatus.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumInteger.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumIntegerOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumHeaderStringParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryDoubleParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZebraType.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClassZeroBasedEnum.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Apple.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Banana.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Fruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/AnotherFakeApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeClassnameTags123Api.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/StoreApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/UserApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Activity.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ActivityOutputElementRepresentation.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AdditionalPropertiesClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Animal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ApiResponse.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Apple.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AppleReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfArrayOfNumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfNumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Banana.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BananaReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BasquePig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Capitalization.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Cat.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Category.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ChildCat.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ClassModel.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ComplexQuadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DanishPig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DeprecatedObject.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Dog.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Drawing.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumArrays.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EquilateralTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/File.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FileSchemaTestClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Foo.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FooGetDefaultResponse.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Fruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FruitReq.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GmFruit.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GrandparentAnimal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HasOnlyReadOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HealthCheckResult.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/IsoscelesTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/List.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/LiteralStringClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Mammal.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MapTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixLog.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Model200Response.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ModelClient.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Name.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NotificationtestGetElementsV1ResponseMPayload.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableGuidClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableShape.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NumberOnly.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ObjectWithDeprecatedFields.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OneOfString.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Order.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterComposite.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnum.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumDefaultValue.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumInteger.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumIntegerDefaultValue.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumTest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ParentPet.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pet.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pig.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/PolymorphicProperty.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Quadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/QuadrilateralInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ReadOnlyFirst.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RequiredClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Return.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHash.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHashRole.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ScaleneTriangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Shape.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeOrNull.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SimpleQuadrilateral.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SpecialModelName.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Tag.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordList.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordListObject.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Triangle.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TriangleInterface.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/User.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Whale.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Zebra.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnum.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnumClass.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/UserApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AnimalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CatTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CategoryTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DogTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DrawingTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ListTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MammalTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MapTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixLogTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NameTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OrderTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PetTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PigTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReturnTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TagTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/UserTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/WhaleTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZebraTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiKeyToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BasicToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BearerToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/OAuthToken.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixLog.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnum.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumInteger.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumTest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.gitignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator-ignore create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/VERSION create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/Org.OpenAPITools.sln create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/api/openapi.yaml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/appveyor.yml create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/apis/DefaultApi.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/models/NowGet200Response.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.ps1 create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.sh create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Model/NowGet200ResponseTests.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/README.md create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/IApi.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiException.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiFactory.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/CookieContainer.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/Option.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenBase.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenContainer`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenProvider`1.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Org.OpenAPITools.csproj create mode 100644 samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/README.md diff --git a/.github/workflows/openapi-generator.yaml b/.github/workflows/openapi-generator.yaml index 6070ca97d95b..77f71dce9575 100644 --- a/.github/workflows/openapi-generator.yaml +++ b/.github/workflows/openapi-generator.yaml @@ -151,7 +151,16 @@ jobs: rm -rf samples/client/petstore/csharp/generichost/net8/Petstore rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate + rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore + + rm -rf samples/client/petstore/csharp/generichost/net8/AllOf + rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf + rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare + rm -rf samples/client/petstore/csharp/generichost/net8/FormModels + rm -rf samples/client/petstore/csharp/generichost/net8/OneOf + rm -rf samples/client/petstore/csharp/generichost/net8/Petstore + rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate - name: Generate samples run: | bash bin/generate-samples.sh diff --git a/.github/workflows/samples-dotnet-net47.yaml b/.github/workflows/samples-dotnet-net47.yaml new file mode 100644 index 000000000000..932326d79f9c --- /dev/null +++ b/.github/workflows/samples-dotnet-net47.yaml @@ -0,0 +1,32 @@ +name: Samples C# .Net 4.7 Clients + +on: + push: + paths: + - samples/client/petstore/csharp/generichost/net4.7/** + pull_request: + paths: + - samples/client/petstore/csharp/generichost/net4.7/** +jobs: + build: + name: Build .Net projects + runs-on: windows-2019 + strategy: + fail-fast: false + matrix: + sample: + - samples/client/petstore/csharp/generichost/net4.7/AllOf + - samples/client/petstore/csharp/generichost/net4.7/AnyOf + - samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare + - samples/client/petstore/csharp/generichost/net4.7/FormModels + - samples/client/petstore/csharp/generichost/net4.7/OneOf + - samples/client/petstore/csharp/generichost/net4.7/Petstore + - samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate + steps: + - uses: actions/checkout@v4 + - 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/appveyor.yml b/appveyor.yml index b0d30b217bfb..34e0a2a14d27 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,8 +54,17 @@ test_script: - dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\generichost\net8\SourceGeneration\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\AllOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\AnyOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\AnyOfNoCompare\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\FormModels\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\OneOf\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\generichost\net8\UseDateTimeForDate\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj + - dotnet test samples\client\petstore\csharp\httpclient\standard2.0\Petstore\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj - dotnet test samples\client\petstore\csharp\restsharp\net4.7\MultipleFrameworks\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj diff --git a/bin/configs/csharp-generichost-net4.7-allOf.yaml b/bin/configs/csharp-generichost-net4.7-allOf.yaml new file mode 100644 index 000000000000..ab7a40a46b4a --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-allOf.yaml @@ -0,0 +1,13 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/AllOf +inputSpec: modules/openapi-generator/src/test/resources/3_0/allOf.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: true + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 diff --git a/bin/configs/csharp-generichost-net4.7-anyOf.yaml b/bin/configs/csharp-generichost-net4.7-anyOf.yaml new file mode 100644 index 000000000000..5552241d9424 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-anyOf.yaml @@ -0,0 +1,13 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/AnyOf +inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: true + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 diff --git a/bin/configs/csharp-generichost-net4.7-anyOfNoCompare.yaml b/bin/configs/csharp-generichost-net4.7-anyOfNoCompare.yaml new file mode 100644 index 000000000000..7ebaa6835766 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-anyOfNoCompare.yaml @@ -0,0 +1,13 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare +inputSpec: modules/openapi-generator/src/test/resources/3_0/anyOf.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: false + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 diff --git a/bin/configs/csharp-generichost-net4.7-formModels.yaml b/bin/configs/csharp-generichost-net4.7-formModels.yaml new file mode 100644 index 000000000000..fb62b3e616f5 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-formModels.yaml @@ -0,0 +1,16 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/FormModels +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: true + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 + skipFormModel: false +inlineSchemaOptions: + RESOLVE_INLINE_ENUMS: true diff --git a/bin/configs/csharp-generichost-net4.7-oneOf.yaml b/bin/configs/csharp-generichost-net4.7-oneOf.yaml new file mode 100644 index 000000000000..353b288ca676 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-oneOf.yaml @@ -0,0 +1,13 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/OneOf +inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: true + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 diff --git a/bin/configs/csharp-generichost-net4.7-useDateTimeForDate.yaml b/bin/configs/csharp-generichost-net4.7-useDateTimeForDate.yaml new file mode 100644 index 000000000000..df99b81be032 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7-useDateTimeForDate.yaml @@ -0,0 +1,10 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/dates-api.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}' + useDateTimeForDate: true + targetFramework: net47 diff --git a/bin/configs/csharp-generichost-net4.7.yaml b/bin/configs/csharp-generichost-net4.7.yaml new file mode 100644 index 000000000000..4ee75448fbc3 --- /dev/null +++ b/bin/configs/csharp-generichost-net4.7.yaml @@ -0,0 +1,13 @@ +# for csharp generichost +generatorName: csharp +outputDir: samples/client/petstore/csharp/generichost/net4.7/Petstore +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +library: generichost +templateDir: modules/openapi-generator/src/main/resources/csharp +additionalProperties: + packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' + useCompareNetObjects: true + disallowAdditionalPropertiesIfNotPresent: false + nullableReferenceTypes: false + equatable: true + targetFramework: net47 diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache index 12fd56a6f9e2..5b097c2241dc 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiResponse`1.mustache @@ -164,7 +164,7 @@ namespace {{packageName}}.{{clientPackage}} /// /// /// - bool Try{{.}}({{^netStandard}}[NotNullWhen(true)]{{/netStandard}}out TType{{nrt?}} result); + bool Try{{.}}({{#net60OrLater}}[NotNullWhen(true)]{{/net60OrLater}}out TType{{nrt?}} result); } {{/x-http-statuses-with-return}} } diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache index f0087b1dfc6f..96bedfa464ec 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/AsModel.mustache @@ -1,4 +1,4 @@ // This logic may be modified with the AsModel.mustache template return Is{{vendorExtensions.x-http-status}} ? System.Text.Json.JsonSerializer.Deserialize<{{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}>(RawContent, _jsonSerializerOptions) - : {{^netStandard}}null{{/netStandard}}{{#netStandard}}default{{/netStandard}}; + : {{#net60OrLater}}null{{/net60OrLater}}{{^net60OrLater}}default{{/net60OrLater}}; diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache index d2917e451950..271dfa6789b8 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ClientUtils.mustache @@ -103,7 +103,7 @@ using System.Runtime.CompilerServices; /// /// /// - public static bool TryDeserialize(string json, JsonSerializerOptions options, {{^netStandard}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/netStandard}}out T{{#nrt}}{{^netStandard}}?{{/netStandard}}{{/nrt}} result) + public static bool TryDeserialize(string json, JsonSerializerOptions options, {{#net60OrLater}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/net60OrLater}}out T{{#nrt}}{{#net60OrLater}}?{{/net60OrLater}}{{/nrt}} result) { try { @@ -125,7 +125,7 @@ using System.Runtime.CompilerServices; /// /// /// - public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, {{^netStandard}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/netStandard}}out T{{#nrt}}{{^netStandard}}?{{/netStandard}}{{/nrt}} result) + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, {{#net60OrLater}}[System.Diagnostics.CodeAnalysis.NotNullWhen(true)] {{/net60OrLater}}out T{{#nrt}}{{#net60OrLater}}?{{/net60OrLater}}{{/nrt}} result) { try { diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/RateLimitProvider`1.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/RateLimitProvider`1.mustache index a2294050f0da..4e44b3fd5ba5 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/RateLimitProvider`1.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/RateLimitProvider`1.mustache @@ -7,12 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; -{{^netStandard}} using System.Threading.Channels; -{{/netStandard}} -{{#netStandard}} -using System.Threading.Channels; -{{/netStandard}} namespace {{packageName}}.{{clientPackage}} { diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache index ac482b8d2742..eccb02d53186 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache @@ -606,13 +606,13 @@ namespace {{packageName}}.{{apiPackage}} httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); {{/-first}} {{/produces}} - {{^netStandard}} + {{#net60OrLater}} httpRequestMessageLocalVar.Method = HttpMethod.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}; - {{/netStandard}} - {{#netStandard}} + {{/net60OrLater}} + {{^net60OrLater}} httpRequestMessageLocalVar.Method = new HttpMethod("{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}"); - {{/netStandard}} + {{/net60OrLater}} DateTime requestedAtLocalVar = DateTime.UtcNow; @@ -747,7 +747,7 @@ namespace {{packageName}}.{{apiPackage}} /// /// /// - public bool Try{{vendorExtensions.x-http-status}}({{^netStandard}}[NotNullWhen(true)]{{/netStandard}}out {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} result) + public bool Try{{vendorExtensions.x-http-status}}({{#net60OrLater}}[NotNullWhen(true)]{{/net60OrLater}}out {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} result) { result = null; diff --git a/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache b/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache index a7113a6cb80b..4135d3cbc823 100644 --- a/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/netcore_project.mustache @@ -32,27 +32,30 @@ {{/useGenericHost}} - {{#useRestSharp}} + {{#useRestSharp}} - {{/useRestSharp}} - {{#useGenericHost}} + {{/useRestSharp}} + {{#useGenericHost}} - {{#supportsRetry}} + {{#supportsRetry}} - {{/supportsRetry}} - {{#net80OrLater}} + {{/supportsRetry}} + {{#net80OrLater}} - {{/net80OrLater}} - {{#netStandard}} + {{/net80OrLater}} + {{^net60OrLater}} - {{/netStandard}} - {{/useGenericHost}} - {{^useGenericHost}} - {{#supportsRetry}} + {{#net47OrLater}} + + {{/net47OrLater}} + {{/net60OrLater}} + {{/useGenericHost}} + {{^useGenericHost}} + {{#supportsRetry}} - {{/supportsRetry}} - {{/useGenericHost}} + {{/supportsRetry}} + {{/useGenericHost}} {{#validatable}} {{^net60OrLater}} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.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/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.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/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES new file mode 100644 index 000000000000..47b2b9b5c4f4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/FILES @@ -0,0 +1,40 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/DefaultApi.md +docs/models/Adult.md +docs/models/Child.md +docs/models/Person.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Adult.cs +src/Org.OpenAPITools/Model/Child.cs +src/Org.OpenAPITools/Model/Person.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/AllOf/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/README.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/AllOf/api/openapi.yaml new file mode 100644 index 000000000000..a6144ccdba8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/api/openapi.yaml @@ -0,0 +1,71 @@ +openapi: 3.0.1 +info: + license: + name: MIT + title: Example + version: 1.0.0 +servers: +- url: http://api.example.xyz/v1 +paths: + /person/display/{personId}: + get: + operationId: list + parameters: + - description: The id of the person to retrieve + explode: false + in: path + name: personId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Person' + description: OK +components: + schemas: + Person: + discriminator: + mapping: + a: '#/components/schemas/Adult' + c: Child + propertyName: $_type + example: + lastName: lastName + firstName: firstName + $_type: $_type + properties: + $_type: + type: string + lastName: + type: string + firstName: + type: string + type: object + Adult: + allOf: + - $ref: '#/components/schemas/Person' + - properties: + children: + items: + $ref: '#/components/schemas/Child' + type: array + type: object + description: A representation of an adult + Child: + allOf: + - properties: + age: + format: int32 + type: integer + type: object + - $ref: '#/components/schemas/Person' + description: A representation of a child + properties: + boosterSeat: + type: boolean + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/AllOf/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..c203cd813bb0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/apis/DefaultApi.md @@ -0,0 +1,95 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://api.example.xyz/v1* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**List**](DefaultApi.md#list) | **GET** /person/display/{personId} | | + + +# **List** +> Person List (string personId) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class ListExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://api.example.xyz/v1"; + var apiInstance = new DefaultApi(config); + var personId = "personId_example"; // string | The id of the person to retrieve + + try + { + Person result = apiInstance.List(personId); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.List: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the ListWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.ListWithHttpInfo(personId); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.ListWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **personId** | **string** | The id of the person to retrieve | | + +### Return type + +[**Person**](Person.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Adult.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Adult.md new file mode 100644 index 000000000000..4bf74e4efc9b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Adult.md @@ -0,0 +1,14 @@ +# Org.OpenAPITools.Model.Adult +A representation of an adult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**FirstName** | **string** | | [optional] +**LastName** | **string** | | [optional] +**Type** | **string** | | [optional] +**Children** | [**List<Child>**](Child.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Child.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Child.md new file mode 100644 index 000000000000..bb2a1e5a5613 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Child.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Child +A representation of a child + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**FirstName** | **string** | | [optional] +**LastName** | **string** | | [optional] +**Type** | **string** | | [optional] +**Age** | **int** | | [optional] +**BoosterSeat** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Person.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Person.md new file mode 100644 index 000000000000..42c19689f9a1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/models/Person.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**FirstName** | **string** | | [optional] +**LastName** | **string** | | [optional] +**Type** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..5dd80394d3fc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,58 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..8181a987b5ff --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,65 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test List + /// + [Fact (Skip = "not implemented")] + public async Task ListAsyncTest() + { + string personId = default; + var response = await _instance.ListAsync(personId); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..470d080ffd63 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,103 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/AdultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/AdultTests.cs new file mode 100644 index 000000000000..31079eac9742 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/AdultTests.cs @@ -0,0 +1,65 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Adult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AdultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Adult + //private Adult instance; + + public AdultTests() + { + // TODO uncomment below to create an instance of Adult + //instance = new Adult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Adult + /// + [Fact] + public void AdultInstanceTest() + { + // TODO uncomment below to test "IsType" Adult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Children' + /// + [Fact] + public void ChildrenTest() + { + // TODO unit test for the property 'Children' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/ChildTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/ChildTests.cs new file mode 100644 index 000000000000..17720f6e735f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/ChildTests.cs @@ -0,0 +1,74 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Child + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ChildTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Child + //private Child instance; + + public ChildTests() + { + // TODO uncomment below to create an instance of Child + //instance = new Child(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Child + /// + [Fact] + public void ChildInstanceTest() + { + // TODO uncomment below to test "IsType" Child + //Assert.IsType(instance); + } + + /// + /// Test the property 'Age' + /// + [Fact] + public void AgeTest() + { + // TODO unit test for the property 'Age' + } + + /// + /// Test the property 'BoosterSeat' + /// + [Fact] + public void BoosterSeatTest() + { + // TODO unit test for the property 'BoosterSeat' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/PersonTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/PersonTests.cs new file mode 100644 index 000000000000..aa3fc482188d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Model/PersonTests.cs @@ -0,0 +1,103 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Person + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PersonTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Person + //private Person instance; + + public PersonTests() + { + // TODO uncomment below to create an instance of Person + //instance = new Person(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Person + /// + [Fact] + public void PersonInstanceTest() + { + // TODO uncomment below to test "IsType" Person + //Assert.IsType(instance); + } + + /// + /// Test deserialize a Adult from type Person + /// + [Fact] + public void AdultDeserializeFromPersonTest() + { + // TODO uncomment below to test deserialize a Adult from type Person + //Assert.IsType(JsonConvert.DeserializeObject(new Adult().ToJson())); + } + + /// + /// Test deserialize a Child from type Person + /// + [Fact] + public void ChildDeserializeFromPersonTest() + { + // TODO uncomment below to test deserialize a Child from type Person + //Assert.IsType(JsonConvert.DeserializeObject(new Child().ToJson())); + } + + /// + /// Test the property 'FirstName' + /// + [Fact] + public void FirstNameTest() + { + // TODO unit test for the property 'FirstName' + } + + /// + /// Test the property 'LastName' + /// + [Fact] + public void LastNameTest() + { + // TODO unit test for the property 'LastName' + } + + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..7b111e173ae9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,355 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The id of the person to retrieve + /// Cancellation Token to cancel the request. + /// <> + Task ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// The id of the person to retrieve + /// Cancellation Token to cancel the request. + /// <> + Task ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IListApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnList; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorList; + + internal void ExecuteOnList(DefaultApi.ListApiResponse apiResponse) + { + OnList?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorList(Exception exception) + { + OnErrorList?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + } + + partial void FormatList(ref string personId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateList(string personId) + { + if (personId == null) + throw new ArgumentNullException(nameof(personId)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterListDefaultImplementation(IListApiResponse apiResponseLocalVar, string personId) + { + bool suppressDefaultLog = false; + AfterList(ref suppressDefaultLog, apiResponseLocalVar, personId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterList(ref bool suppressDefaultLog, IListApiResponse apiResponseLocalVar, string personId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorListDefaultImplementation(Exception exception, string pathFormat, string path, string personId) + { + bool suppressDefaultLog = false; + OnErrorList(ref suppressDefaultLog, exception, pathFormat, path, personId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorList(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string personId); + + /// + /// + /// + /// The id of the person to retrieve + /// Cancellation Token to cancel the request. + /// <> + public async Task ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await ListAsync(personId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// The id of the person to retrieve + /// Cancellation Token to cancel the request. + /// <> + public async Task ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateList(personId); + + FormatList(ref personId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/person/display/{personId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpersonId%7D", Uri.EscapeDataString(personId.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + ListApiResponse apiResponseLocalVar = new ListApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterListDefaultImplementation(apiResponseLocalVar, personId); + + Events.ExecuteOnList(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorListDefaultImplementation(e, "/person/display/{personId}", uriBuilderLocalVar.Path, personId); + Events.ExecuteOnErrorList(e); + throw; + } + } + + /// + /// The + /// + public partial class ListApiResponse : Org.OpenAPITools.Client.ApiResponse, IListApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public ListApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Person Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Person result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..78fdad8039f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..16e55f8c7b90 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,170 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..8ea796e81693 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,329 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using KellermanSoftware.CompareNetObjects; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static constructor to initialise compareLogic. + /// + static ClientUtils() + { + ComparisonConfig comparisonConfig = new ComparisonConfig(); + comparisonConfig.UseHashCodeIdentifier = true; + compareLogic = new CompareLogic(comparisonConfig); + } + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://api.example.xyz/v1"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = "/v1"; + + /// + /// The host of the API + /// + public const string HOST = "api.example.xyz"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..a7f3806b960f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..c818977618f2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..7b7d86c3238e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,131 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new AdultJsonConverter()); + _jsonOptions.Converters.Add(new ChildJsonConverter()); + _jsonOptions.Converters.Add(new PersonJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..0b113d11177e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..53ad628a9a3f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,55 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..ed829aca7729 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..2221ca651c62 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,57 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..a4c5431cf87b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..3995735c8ce1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static void AddApi(this IServiceCollection services) + { + HostConfiguration config = new HostConfiguration(services); + AddApi(services, config); + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs new file mode 100644 index 000000000000..7806add08bde --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs @@ -0,0 +1,205 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// A representation of an adult + /// + public partial class Adult : Person, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// children + /// firstName + /// lastName + [JsonConstructor] + public Adult(Option> children = default, Option firstName = default, Option lastName = default) : base(firstName, lastName) + { + ChildrenOption = children; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Children + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ChildrenOption { get; private set; } + + /// + /// Gets or Sets Children + /// + [JsonPropertyName("children")] + public List Children { get { return this.ChildrenOption; } set { this.ChildrenOption = new Option>(value); } } + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string Type { get; } = "Adult"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Adult {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Children: ").Append(Children).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class AdultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Adult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> children = default; + Option firstName = default; + Option lastName = default; + Option type = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "children": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + children = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "$_type": + type = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (children.IsSet && children.Value == null) + throw new ArgumentNullException(nameof(children), "Property is not nullable for class Adult."); + + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Adult."); + + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Adult."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult."); + + return new Adult(children, firstName, lastName); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, adult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions) + { + if (adult.ChildrenOption.IsSet && adult.Children == null) + throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult."); + + if (adult.FirstNameOption.IsSet && adult.FirstName == null) + throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult."); + + if (adult.LastNameOption.IsSet && adult.LastName == null) + throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult."); + + if (adult.ChildrenOption.IsSet) + { + writer.WritePropertyName("children"); + JsonSerializer.Serialize(writer, adult.Children, jsonSerializerOptions); + } + if (adult.FirstNameOption.IsSet) + writer.WriteString("firstName", adult.FirstName); + + if (adult.LastNameOption.IsSet) + writer.WriteString("lastName", adult.LastName); + + writer.WriteString("$_type", adult.Type); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs new file mode 100644 index 000000000000..35adb6d48805 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Child.cs @@ -0,0 +1,227 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// A representation of a child + /// + public partial class Child : Person, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// age + /// firstName + /// lastName + /// boosterSeat + [JsonConstructor] + public Child(Option age = default, Option firstName = default, Option lastName = default, Option boosterSeat = default) : base(firstName, lastName) + { + AgeOption = age; + BoosterSeatOption = boosterSeat; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Age + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AgeOption { get; private set; } + + /// + /// Gets or Sets Age + /// + [JsonPropertyName("age")] + public int? Age { get { return this.AgeOption; } set { this.AgeOption = new Option(value); } } + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string Type { get; } = "Child"; + + /// + /// Used to track the state of BoosterSeat + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoosterSeatOption { get; private set; } + + /// + /// Gets or Sets BoosterSeat + /// + [JsonPropertyName("boosterSeat")] + public bool? BoosterSeat { get { return this.BoosterSeatOption; } set { this.BoosterSeatOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Child {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Age: ").Append(Age).Append("\n"); + sb.Append(" BoosterSeat: ").Append(BoosterSeat).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class ChildJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Child Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option age = default; + Option firstName = default; + Option lastName = default; + Option type = default; + Option boosterSeat = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "age": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + age = new Option(utf8JsonReader.GetInt32()); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "$_type": + type = new Option(utf8JsonReader.GetString()); + break; + case "boosterSeat": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + boosterSeat = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (age.IsSet && age.Value == null) + throw new ArgumentNullException(nameof(age), "Property is not nullable for class Child."); + + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Child."); + + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Child."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Child."); + + if (boosterSeat.IsSet && boosterSeat.Value == null) + throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child."); + + return new Child(age, firstName, lastName, boosterSeat); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, child, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions) + { + if (child.FirstNameOption.IsSet && child.FirstName == null) + throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child."); + + if (child.LastNameOption.IsSet && child.LastName == null) + throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child."); + + if (child.AgeOption.IsSet) + writer.WriteNumber("age", child.AgeOption.Value.Value); + + if (child.FirstNameOption.IsSet) + writer.WriteString("firstName", child.FirstName); + + if (child.LastNameOption.IsSet) + writer.WriteString("lastName", child.LastName); + + writer.WriteString("$_type", child.Type); + + if (child.BoosterSeatOption.IsSet) + writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs new file mode 100644 index 000000000000..88d20491e280 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Person.cs @@ -0,0 +1,247 @@ +// +/* + * Example + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Person + /// + public partial class Person : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// firstName + /// lastName + [JsonConstructor] + public Person(Option firstName = default, Option lastName = default) + { + FirstNameOption = firstName; + LastNameOption = lastName; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string FirstName { get { return this.FirstNameOption; } set { this.FirstNameOption = new Option(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string LastName { get { return this.LastNameOption; } set { this.LastNameOption = new Option(value); } } + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string Type { get; } = "Person"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Person {\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PersonJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option firstName = default; + Option lastName = default; + Option type = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$_type"); + + if (discriminator != null && discriminator.Equals("Adult")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + if (discriminator != null && discriminator.Equals("Child")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "$_type": + type = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Person."); + + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Person."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person."); + + return new Person(firstName, lastName); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions) + { + if (person is Adult adult){ + JsonSerializer.Serialize(writer, adult, jsonSerializerOptions); + return; + } + + if (person is Child child){ + JsonSerializer.Serialize(writer, child, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, person, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions) + { + if (person.FirstNameOption.IsSet && person.FirstName == null) + throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person."); + + if (person.LastNameOption.IsSet && person.LastName == null) + throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person."); + + if (person.FirstNameOption.IsSet) + writer.WriteString("firstName", person.FirstName); + + if (person.LastNameOption.IsSet) + writer.WriteString("lastName", person.LastName); + + writer.WriteString("$_type", person.Type); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..c6529e054024 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,33 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..b1d4b2803c75 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/README.md @@ -0,0 +1,177 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + ListApiResponse apiResponse = await api.ListAsync("todo"); + Person model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + +Endpoints do not require authorization. + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: Example +- appVersion: 1.0.0 +- appDescription: No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.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/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.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/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES new file mode 100644 index 000000000000..59cc1ea25a08 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/FILES @@ -0,0 +1,40 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/DefaultApi.md +docs/models/Apple.md +docs/models/Banana.md +docs/models/Fruit.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Apple.cs +src/Org.OpenAPITools/Model/Banana.cs +src/Org.OpenAPITools/Model/Fruit.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/api/openapi.yaml new file mode 100644 index 000000000000..25b9adb5f50a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/api/openapi.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.1 +info: + title: fruity + version: 0.0.1 +servers: +- url: / +paths: + /: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/fruit' + description: desc +components: + schemas: + fruit: + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + example: + color: color + properties: + color: + type: string + title: fruit + type: object + apple: + properties: + kind: + type: string + title: apple + type: object + banana: + properties: + count: + type: number + title: banana + type: object + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..bccf3af9c516 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/apis/DefaultApi.md @@ -0,0 +1,90 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**RootGet**](DefaultApi.md#rootget) | **GET** / | | + + +# **RootGet** +> Fruit RootGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class RootGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://localhost"; + var apiInstance = new DefaultApi(config); + + try + { + Fruit result = apiInstance.RootGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.RootGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the RootGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.RootGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.RootGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**Fruit**](Fruit.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | desc | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Apple.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Apple.md new file mode 100644 index 000000000000..95f575834399 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Apple.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Kind** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Banana.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Banana.md new file mode 100644 index 000000000000..c9aea6fb56c8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Banana.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Count** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Fruit.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Fruit.md new file mode 100644 index 000000000000..b3bee18f7ba0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/models/Fruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..5a82cd6c99de --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,58 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..b7bcc281037a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,64 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test RootGet + /// + [Fact (Skip = "not implemented")] + public async Task RootGetAsyncTest() + { + var response = await _instance.RootGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..c9833ec353ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,103 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs new file mode 100644 index 000000000000..483628b6a4a0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Apple + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Apple + //private Apple instance; + + public AppleTests() + { + // TODO uncomment below to create an instance of Apple + //instance = new Apple(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Apple + /// + [Fact] + public void AppleInstanceTest() + { + // TODO uncomment below to test "IsType" Apple + //Assert.IsType(instance); + } + + /// + /// Test the property 'Kind' + /// + [Fact] + public void KindTest() + { + // TODO unit test for the property 'Kind' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs new file mode 100644 index 000000000000..5befec8d7e5f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Banana + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Banana + //private Banana instance; + + public BananaTests() + { + // TODO uncomment below to create an instance of Banana + //instance = new Banana(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Banana + /// + [Fact] + public void BananaInstanceTest() + { + // TODO uncomment below to test "IsType" Banana + //Assert.IsType(instance); + } + + /// + /// Test the property 'Count' + /// + [Fact] + public void CountTest() + { + // TODO unit test for the property 'Count' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs new file mode 100644 index 000000000000..a6607ae5d56d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Fruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Fruit + //private Fruit instance; + + public FruitTests() + { + // TODO uncomment below to create an instance of Fruit + //instance = new Fruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Fruit + /// + [Fact] + public void FruitInstanceTest() + { + // TODO uncomment below to test "IsType" Fruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..8ea8bdbe84e9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,329 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IRootGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnRootGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorRootGet; + + internal void ExecuteOnRootGet(DefaultApi.RootGetApiResponse apiResponse) + { + OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorRootGet(Exception exception) + { + OnErrorRootGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + } + + /// + /// Processes the server response + /// + /// + private void AfterRootGetDefaultImplementation(IRootGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterRootGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterRootGet(ref bool suppressDefaultLog, IRootGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorRootGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorRootGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await RootGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + + AfterRootGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnRootGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRootGet(e); + throw; + } + } + + /// + /// The + /// + public partial class RootGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRootGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public RootGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Fruit Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Fruit result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..1d43e69742f6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..de1f5521df66 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,170 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..91e5f4c09c08 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,329 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using KellermanSoftware.CompareNetObjects; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static constructor to initialise compareLogic. + /// + static ClientUtils() + { + ComparisonConfig comparisonConfig = new ComparisonConfig(); + comparisonConfig.UseHashCodeIdentifier = true; + compareLogic = new CompareLogic(comparisonConfig); + } + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://localhost"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = ""; + + /// + /// The host of the API + /// + public const string HOST = "localhost"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..68e90f4ecbb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..3cb4b6ce51e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..a90199eebd63 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,131 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new AppleJsonConverter()); + _jsonOptions.Converters.Add(new BananaJsonConverter()); + _jsonOptions.Converters.Add(new FruitJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..55d56f3f2049 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..8e7bed46e9c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,55 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..3924246ab7c2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..df405f3894d4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,57 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..e1dec11976d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..2e27cceb8d12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static void AddApi(this IServiceCollection services) + { + HostConfiguration config = new HostConfiguration(services); + AddApi(services, config); + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs new file mode 100644 index 000000000000..dad28e7397be --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Apple.cs @@ -0,0 +1,174 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Apple + /// + public partial class Apple : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// kind + [JsonConstructor] + public Apple(Option kind = default) + { + KindOption = kind; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Kind + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option KindOption { get; private set; } + + /// + /// Gets or Sets Kind + /// + [JsonPropertyName("kind")] + public string Kind { get { return this.KindOption; } set { this.KindOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Apple {\n"); + sb.Append(" Kind: ").Append(Kind).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option kind = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "kind": + kind = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (kind.IsSet && kind.Value == null) + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); + + return new Apple(kind); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apple, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + if (apple.KindOption.IsSet && apple.Kind == null) + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); + + if (apple.KindOption.IsSet) + writer.WriteString("kind", apple.Kind); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs new file mode 100644 index 000000000000..3041dedf17d3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Banana.cs @@ -0,0 +1,172 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Banana + /// + public partial class Banana : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// count + [JsonConstructor] + public Banana(Option count = default) + { + CountOption = count; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Count + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountOption { get; private set; } + + /// + /// Gets or Sets Count + /// + [JsonPropertyName("count")] + public decimal? Count { get { return this.CountOption; } set { this.CountOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Banana {\n"); + sb.Append(" Count: ").Append(Count).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option count = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "count": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + count = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (count.IsSet && count.Value == null) + throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana."); + + return new Banana(count); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, banana, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + if (banana.CountOption.IsSet) + writer.WriteNumber("count", banana.CountOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs new file mode 100644 index 000000000000..17d77f68135c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -0,0 +1,242 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Fruit + /// + public partial class Fruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// color + public Fruit(Option apple, Option banana, Option color = default) + { + AppleOption = apple; + BananaOption = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new Option(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Fruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); + + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new Fruit(appleParsedValue, bananaParsedValue, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null) + { + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(writer, fruit.AppleOption.Value, jsonSerializerOptions); + } + + if (fruit.BananaOption.IsSet && fruit.BananaOption.Value != null) + { + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, fruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..c6529e054024 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,33 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..67b671efd196 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOf/src/Org.OpenAPITools/README.md @@ -0,0 +1,177 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + RootGetApiResponse apiResponse = await api.RootGetAsync("todo"); + Fruit model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + +Endpoints do not require authorization. + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: fruity +- appVersion: 0.0.1 +- appDescription: No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.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/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.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/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES new file mode 100644 index 000000000000..59cc1ea25a08 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/FILES @@ -0,0 +1,40 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/DefaultApi.md +docs/models/Apple.md +docs/models/Banana.md +docs/models/Fruit.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Apple.cs +src/Org.OpenAPITools/Model/Banana.cs +src/Org.OpenAPITools/Model/Fruit.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/api/openapi.yaml new file mode 100644 index 000000000000..25b9adb5f50a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/api/openapi.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.1 +info: + title: fruity + version: 0.0.1 +servers: +- url: / +paths: + /: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/fruit' + description: desc +components: + schemas: + fruit: + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + example: + color: color + properties: + color: + type: string + title: fruit + type: object + apple: + properties: + kind: + type: string + title: apple + type: object + banana: + properties: + count: + type: number + title: banana + type: object + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..bccf3af9c516 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/apis/DefaultApi.md @@ -0,0 +1,90 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**RootGet**](DefaultApi.md#rootget) | **GET** / | | + + +# **RootGet** +> Fruit RootGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class RootGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://localhost"; + var apiInstance = new DefaultApi(config); + + try + { + Fruit result = apiInstance.RootGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.RootGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the RootGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.RootGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.RootGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**Fruit**](Fruit.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | desc | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Apple.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Apple.md new file mode 100644 index 000000000000..95f575834399 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Apple.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Kind** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Banana.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Banana.md new file mode 100644 index 000000000000..c9aea6fb56c8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Banana.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Count** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Fruit.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Fruit.md new file mode 100644 index 000000000000..b3bee18f7ba0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/models/Fruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..5a82cd6c99de --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,58 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..b7bcc281037a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,64 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test RootGet + /// + [Fact (Skip = "not implemented")] + public async Task RootGetAsyncTest() + { + var response = await _instance.RootGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..c9833ec353ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,103 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/AppleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/AppleTests.cs new file mode 100644 index 000000000000..483628b6a4a0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/AppleTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Apple + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Apple + //private Apple instance; + + public AppleTests() + { + // TODO uncomment below to create an instance of Apple + //instance = new Apple(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Apple + /// + [Fact] + public void AppleInstanceTest() + { + // TODO uncomment below to test "IsType" Apple + //Assert.IsType(instance); + } + + /// + /// Test the property 'Kind' + /// + [Fact] + public void KindTest() + { + // TODO unit test for the property 'Kind' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/BananaTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/BananaTests.cs new file mode 100644 index 000000000000..5befec8d7e5f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/BananaTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Banana + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Banana + //private Banana instance; + + public BananaTests() + { + // TODO uncomment below to create an instance of Banana + //instance = new Banana(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Banana + /// + [Fact] + public void BananaInstanceTest() + { + // TODO uncomment below to test "IsType" Banana + //Assert.IsType(instance); + } + + /// + /// Test the property 'Count' + /// + [Fact] + public void CountTest() + { + // TODO unit test for the property 'Count' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/FruitTests.cs new file mode 100644 index 000000000000..a6607ae5d56d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Fruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Fruit + //private Fruit instance; + + public FruitTests() + { + // TODO uncomment below to create an instance of Fruit + //instance = new Fruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Fruit + /// + [Fact] + public void FruitInstanceTest() + { + // TODO uncomment below to test "IsType" Fruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..8ea8bdbe84e9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,329 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IRootGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnRootGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorRootGet; + + internal void ExecuteOnRootGet(DefaultApi.RootGetApiResponse apiResponse) + { + OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorRootGet(Exception exception) + { + OnErrorRootGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + } + + /// + /// Processes the server response + /// + /// + private void AfterRootGetDefaultImplementation(IRootGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterRootGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterRootGet(ref bool suppressDefaultLog, IRootGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorRootGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorRootGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await RootGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + + AfterRootGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnRootGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRootGet(e); + throw; + } + } + + /// + /// The + /// + public partial class RootGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRootGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public RootGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Fruit Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Fruit result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..1d43e69742f6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..de1f5521df66 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,170 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..4c9be2b60cfa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,314 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://localhost"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = ""; + + /// + /// The host of the API + /// + public const string HOST = "localhost"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..68e90f4ecbb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..3cb4b6ce51e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..a90199eebd63 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,131 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new AppleJsonConverter()); + _jsonOptions.Converters.Add(new BananaJsonConverter()); + _jsonOptions.Converters.Add(new FruitJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..55d56f3f2049 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..8e7bed46e9c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,55 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..3924246ab7c2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..df405f3894d4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,57 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..e1dec11976d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..2e27cceb8d12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static void AddApi(this IServiceCollection services) + { + HostConfiguration config = new HostConfiguration(services); + AddApi(services, config); + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs new file mode 100644 index 000000000000..09c52064e93a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs @@ -0,0 +1,173 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Apple + /// + public partial class Apple : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// kind + [JsonConstructor] + public Apple(Option kind = default) + { + KindOption = kind; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Kind + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option KindOption { get; private set; } + + /// + /// Gets or Sets Kind + /// + [JsonPropertyName("kind")] + public string Kind { get { return this.KindOption; } set { this.KindOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Apple {\n"); + sb.Append(" Kind: ").Append(Kind).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option kind = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "kind": + kind = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (kind.IsSet && kind.Value == null) + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); + + return new Apple(kind); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apple, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + if (apple.KindOption.IsSet && apple.Kind == null) + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); + + if (apple.KindOption.IsSet) + writer.WriteString("kind", apple.Kind); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs new file mode 100644 index 000000000000..f07bc3720c04 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs @@ -0,0 +1,171 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Banana + /// + public partial class Banana : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// count + [JsonConstructor] + public Banana(Option count = default) + { + CountOption = count; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Count + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountOption { get; private set; } + + /// + /// Gets or Sets Count + /// + [JsonPropertyName("count")] + public decimal? Count { get { return this.CountOption; } set { this.CountOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Banana {\n"); + sb.Append(" Count: ").Append(Count).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option count = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "count": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + count = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (count.IsSet && count.Value == null) + throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana."); + + return new Banana(count); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, banana, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + if (banana.CountOption.IsSet) + writer.WriteNumber("count", banana.CountOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs new file mode 100644 index 000000000000..983e93f3875b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs @@ -0,0 +1,241 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Fruit + /// + public partial class Fruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// color + public Fruit(Option apple, Option banana, Option color = default) + { + AppleOption = apple; + BananaOption = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new Option(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Fruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); + + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new Fruit(appleParsedValue, bananaParsedValue, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null) + { + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(writer, fruit.AppleOption.Value, jsonSerializerOptions); + } + + if (fruit.BananaOption.IsSet && fruit.BananaOption.Value != null) + { + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, fruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..201640a24d33 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,32 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..f5f00c255456 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/AnyOfNoCompare/src/Org.OpenAPITools/README.md @@ -0,0 +1,176 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + RootGetApiResponse apiResponse = await api.RootGetAsync("todo"); + Fruit model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + +Endpoints do not require authorization. + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: fruity +- appVersion: 0.0.1 +- appDescription: No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.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/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.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/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES new file mode 100644 index 000000000000..99f3f12f924a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES @@ -0,0 +1,280 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/AnotherFakeApi.md +docs/apis/DefaultApi.md +docs/apis/FakeApi.md +docs/apis/FakeClassnameTags123Api.md +docs/apis/PetApi.md +docs/apis/StoreApi.md +docs/apis/UserApi.md +docs/models/Activity.md +docs/models/ActivityOutputElementRepresentation.md +docs/models/AdditionalPropertiesClass.md +docs/models/Animal.md +docs/models/ApiResponse.md +docs/models/Apple.md +docs/models/AppleReq.md +docs/models/ArrayOfArrayOfNumberOnly.md +docs/models/ArrayOfNumberOnly.md +docs/models/ArrayTest.md +docs/models/Banana.md +docs/models/BananaReq.md +docs/models/BasquePig.md +docs/models/Capitalization.md +docs/models/Cat.md +docs/models/Category.md +docs/models/ChildCat.md +docs/models/ChildCatAllOfPetType.md +docs/models/ClassModel.md +docs/models/ComplexQuadrilateral.md +docs/models/DanishPig.md +docs/models/DateOnlyClass.md +docs/models/DeprecatedObject.md +docs/models/Dog.md +docs/models/Drawing.md +docs/models/EnumArrays.md +docs/models/EnumArraysArrayEnumInner.md +docs/models/EnumArraysJustSymbol.md +docs/models/EnumClass.md +docs/models/EnumTest.md +docs/models/EnumTestEnumInteger.md +docs/models/EnumTestEnumIntegerOnly.md +docs/models/EnumTestEnumString.md +docs/models/EquilateralTriangle.md +docs/models/File.md +docs/models/FileSchemaTestClass.md +docs/models/FindPetsByStatusStatusParameterInner.md +docs/models/Foo.md +docs/models/FooGetDefaultResponse.md +docs/models/FormatTest.md +docs/models/Fruit.md +docs/models/FruitReq.md +docs/models/GmFruit.md +docs/models/GrandparentAnimal.md +docs/models/HasOnlyReadOnly.md +docs/models/HealthCheckResult.md +docs/models/IsoscelesTriangle.md +docs/models/List.md +docs/models/LiteralStringClass.md +docs/models/Mammal.md +docs/models/MapTest.md +docs/models/MapTestMapOfEnumStringValue.md +docs/models/MixLog.md +docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/Model200Response.md +docs/models/ModelClient.md +docs/models/Name.md +docs/models/NotificationtestGetElementsV1ResponseMPayload.md +docs/models/NullableClass.md +docs/models/NullableGuidClass.md +docs/models/NullableShape.md +docs/models/NumberOnly.md +docs/models/ObjectWithDeprecatedFields.md +docs/models/OneOfString.md +docs/models/Order.md +docs/models/OrderStatus.md +docs/models/OuterComposite.md +docs/models/OuterEnum.md +docs/models/OuterEnumDefaultValue.md +docs/models/OuterEnumInteger.md +docs/models/OuterEnumIntegerDefaultValue.md +docs/models/OuterEnumTest.md +docs/models/ParentPet.md +docs/models/Pet.md +docs/models/PetStatus.md +docs/models/Pig.md +docs/models/PolymorphicProperty.md +docs/models/Quadrilateral.md +docs/models/QuadrilateralInterface.md +docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md +docs/models/RequiredClassRequiredNotnullableEnumInteger.md +docs/models/RequiredClassRequiredNotnullableEnumIntegerOnly.md +docs/models/RequiredClassRequiredNotnullableEnumString.md +docs/models/RequiredClassRequiredNullableEnumInteger.md +docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md +docs/models/RequiredClassRequiredNullableEnumString.md +docs/models/Return.md +docs/models/RolesReportsHash.md +docs/models/RolesReportsHashRole.md +docs/models/ScaleneTriangle.md +docs/models/Shape.md +docs/models/ShapeInterface.md +docs/models/ShapeOrNull.md +docs/models/SimpleQuadrilateral.md +docs/models/SpecialModelName.md +docs/models/Tag.md +docs/models/TestCollectionEndingWithWordList.md +docs/models/TestCollectionEndingWithWordListObject.md +docs/models/TestEnumParametersEnumHeaderStringParameter.md +docs/models/TestEnumParametersEnumQueryDoubleParameter.md +docs/models/TestEnumParametersEnumQueryIntegerParameter.md +docs/models/TestEnumParametersRequestEnumFormString.md +docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md +docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/Triangle.md +docs/models/TriangleInterface.md +docs/models/User.md +docs/models/Whale.md +docs/models/Zebra.md +docs/models/ZebraType.md +docs/models/ZeroBasedEnum.md +docs/models/ZeroBasedEnumClass.md +docs/models/ZeroBasedEnumClassZeroBasedEnum.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/AnotherFakeApi.cs +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/FakeApi.cs +src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Api/PetApi.cs +src/Org.OpenAPITools/Api/StoreApi.cs +src/Org.OpenAPITools/Api/UserApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiKeyToken.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/BasicToken.cs +src/Org.OpenAPITools/Client/BearerToken.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +src/Org.OpenAPITools/Client/HttpSigningToken.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/OAuthToken.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Activity.cs +src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/Animal.cs +src/Org.OpenAPITools/Model/ApiResponse.cs +src/Org.OpenAPITools/Model/Apple.cs +src/Org.OpenAPITools/Model/AppleReq.cs +src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +src/Org.OpenAPITools/Model/ArrayTest.cs +src/Org.OpenAPITools/Model/Banana.cs +src/Org.OpenAPITools/Model/BananaReq.cs +src/Org.OpenAPITools/Model/BasquePig.cs +src/Org.OpenAPITools/Model/Capitalization.cs +src/Org.OpenAPITools/Model/Cat.cs +src/Org.OpenAPITools/Model/Category.cs +src/Org.OpenAPITools/Model/ChildCat.cs +src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs +src/Org.OpenAPITools/Model/ClassModel.cs +src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs +src/Org.OpenAPITools/Model/DeprecatedObject.cs +src/Org.OpenAPITools/Model/Dog.cs +src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EnumArrays.cs +src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs +src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs +src/Org.OpenAPITools/Model/EnumClass.cs +src/Org.OpenAPITools/Model/EnumTest.cs +src/Org.OpenAPITools/Model/EnumTestEnumInteger.cs +src/Org.OpenAPITools/Model/EnumTestEnumIntegerOnly.cs +src/Org.OpenAPITools/Model/EnumTestEnumString.cs +src/Org.OpenAPITools/Model/EquilateralTriangle.cs +src/Org.OpenAPITools/Model/File.cs +src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +src/Org.OpenAPITools/Model/FindPetsByStatusStatusParameterInner.cs +src/Org.OpenAPITools/Model/Foo.cs +src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +src/Org.OpenAPITools/Model/FormatTest.cs +src/Org.OpenAPITools/Model/Fruit.cs +src/Org.OpenAPITools/Model/FruitReq.cs +src/Org.OpenAPITools/Model/GmFruit.cs +src/Org.OpenAPITools/Model/GrandparentAnimal.cs +src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +src/Org.OpenAPITools/Model/HealthCheckResult.cs +src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +src/Org.OpenAPITools/Model/List.cs +src/Org.OpenAPITools/Model/LiteralStringClass.cs +src/Org.OpenAPITools/Model/Mammal.cs +src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs +src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/Model200Response.cs +src/Org.OpenAPITools/Model/ModelClient.cs +src/Org.OpenAPITools/Model/Name.cs +src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +src/Org.OpenAPITools/Model/NullableClass.cs +src/Org.OpenAPITools/Model/NullableGuidClass.cs +src/Org.OpenAPITools/Model/NullableShape.cs +src/Org.OpenAPITools/Model/NumberOnly.cs +src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +src/Org.OpenAPITools/Model/OneOfString.cs +src/Org.OpenAPITools/Model/Order.cs +src/Org.OpenAPITools/Model/OrderStatus.cs +src/Org.OpenAPITools/Model/OuterComposite.cs +src/Org.OpenAPITools/Model/OuterEnum.cs +src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +src/Org.OpenAPITools/Model/OuterEnumInteger.cs +src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +src/Org.OpenAPITools/Model/OuterEnumTest.cs +src/Org.OpenAPITools/Model/ParentPet.cs +src/Org.OpenAPITools/Model/Pet.cs +src/Org.OpenAPITools/Model/PetStatus.cs +src/Org.OpenAPITools/Model/Pig.cs +src/Org.OpenAPITools/Model/PolymorphicProperty.cs +src/Org.OpenAPITools/Model/Quadrilateral.cs +src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumInteger.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumIntegerOnly.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs +src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs +src/Org.OpenAPITools/Model/Return.cs +src/Org.OpenAPITools/Model/RolesReportsHash.cs +src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +src/Org.OpenAPITools/Model/ScaleneTriangle.cs +src/Org.OpenAPITools/Model/Shape.cs +src/Org.OpenAPITools/Model/ShapeInterface.cs +src/Org.OpenAPITools/Model/ShapeOrNull.cs +src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +src/Org.OpenAPITools/Model/SpecialModelName.cs +src/Org.OpenAPITools/Model/Tag.cs +src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +src/Org.OpenAPITools/Model/TestEnumParametersEnumHeaderStringParameter.cs +src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryDoubleParameter.cs +src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs +src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs +src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs +src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/Triangle.cs +src/Org.OpenAPITools/Model/TriangleInterface.cs +src/Org.OpenAPITools/Model/User.cs +src/Org.OpenAPITools/Model/Whale.cs +src/Org.OpenAPITools/Model/Zebra.cs +src/Org.OpenAPITools/Model/ZebraType.cs +src/Org.OpenAPITools/Model/ZeroBasedEnum.cs +src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +src/Org.OpenAPITools/Model/ZeroBasedEnumClassZeroBasedEnum.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/FormModels/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/README.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml new file mode 100644 index 000000000000..b4ab1bc2b817 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml @@ -0,0 +1,2980 @@ +openapi: 3.0.0 +info: + description: "This spec is mainly for testing Petstore server and contains fake\ + \ endpoints, models. Please do not use this for any other purpose. Special characters:\ + \ \" \\" + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- description: petstore server + url: "http://{server}.swagger.io:{port}/v2" + variables: + server: + default: petstore + enum: + - petstore + - qa-petstore + - dev-petstore + port: + default: "80" + enum: + - "80" + - "8080" +- description: The local server + url: "https://localhost:8080/{version}" + variables: + version: + default: v2 + enum: + - v1 + - v2 +- description: The local server without variables + url: https://127.0.0.1/no_variable +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /roles/report: + get: + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/RolesReport' + type: array + description: returns report + /hello: + get: + description: Hello + operationId: Hello + responses: + "200": + content: + application/json: + schema: + items: + format: uuid + type: string + type: array + description: UUIDs + summary: Hello + /foo: + get: + responses: + default: + content: + application/json: + schema: + $ref: '#/components/schemas/_foo_get_default_response' + description: response + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + "405": + description: Invalid input + security: + - http_signature_test: [] + - 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: + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + servers: + - url: http://petstore.swagger.io/v2 + - url: http://path-server-test.petstore.local/v2 + /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: + $ref: '#/components/schemas/findPetsByStatus_status_parameter_inner' + 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: + - http_signature_test: [] + - petstore_auth: + - write:pets + - 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: + - http_signature_test: [] + - petstore_auth: + - write:pets + - 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: [] + - api_key_query: [] + 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/{order_id}: + 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: order_id + 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: order_id + 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 + summary: Create user + tags: + - user + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: '#/components/requestBodies/UserArray' + responses: + default: + description: successful operation + 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 + 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: + 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 + 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 + 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 + "598": + description: Not a real HTTP status code + "599": + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Not a real HTTP status code with a return object + 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 + summary: Updated user + tags: + - user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + explode: true + in: query + name: required_string_group + required: true + schema: + type: integer + style: form + - description: Required Boolean in group parameters + explode: false + in: header + name: required_boolean_group + required: true + schema: + type: boolean + style: simple + - description: Required Integer in group parameters + explode: true + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + style: form + - description: String in group parameters + explode: true + in: query + name: string_group + required: false + schema: + type: integer + style: form + - description: Boolean in group parameters + explode: false + in: header + name: boolean_group + required: false + schema: + type: boolean + style: simple + - description: Integer in group parameters + explode: true + in: query + name: int64_group + required: false + schema: + format: int64 + type: integer + style: form + responses: + "400": + description: Something wrong + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + required: false + schema: + items: + $ref: '#/components/schemas/testEnumParameters_request_enum_form_string_array_inner' + type: array + style: simple + - description: Header parameter enum test (string) + explode: false + in: header + name: enum_header_string + required: false + schema: + $ref: '#/components/schemas/testEnumParameters_enum_header_string_parameter' + style: simple + - description: Query parameter enum test (string array) + explode: true + in: query + name: enum_query_string_array + required: false + schema: + items: + $ref: '#/components/schemas/testEnumParameters_request_enum_form_string_array_inner' + type: array + style: form + - description: Query parameter enum test (string) + explode: true + in: query + name: enum_query_string + required: false + schema: + $ref: '#/components/schemas/testEnumParameters_enum_header_string_parameter' + style: form + - description: Query parameter enum test (double) + explode: true + in: query + name: enum_query_integer + required: false + schema: + $ref: '#/components/schemas/testEnumParameters_enum_query_integer_parameter' + style: form + - description: Query parameter enum test (double) + explode: true + in: query + name: enum_query_double + required: false + schema: + $ref: '#/components/schemas/testEnumParameters_enum_query_double_parameter' + style: form + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testEnumParameters_request' + responses: + "400": + description: Invalid request + "404": + description: Not found + summary: To test enum parameters + tags: + - fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + post: + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testEndpointParameters_request' + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - http_basic_test: [] + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + parameters: + - description: Required UUID String + explode: true + in: query + name: required_string_uuid + required: true + schema: + format: uuid + type: string + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + /fake/jsonFormData: + get: + description: "" + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testJsonFormData_request' + responses: + "200": + description: successful operation + summary: test json serialization of form data + tags: + - fake + /fake/additionalProperties-reference: + post: + description: "" + operationId: testAdditionalPropertiesReference + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FreeFormObject' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test referenced additionalProperties + tags: + - fake + /fake/stringMap-reference: + post: + description: "" + operationId: testStringMapReference + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MapOfString' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test referenced string map + tags: + - fake + /fake/inline-additionalProperties: + post: + description: "" + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + description: successful operation + summary: test inline additionalProperties + tags: + - fake + /fake/inline-freeform-additionalProperties: + post: + description: "" + operationId: testInlineFreeformAdditionalProperties + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/testInlineFreeformAdditionalProperties_request' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test inline free-form additionalProperties + tags: + - fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - explode: true + in: query + name: query + required: true + schema: + type: string + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + description: Success + tags: + - fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + /fake/body-with-file-schema: + put: + description: "For this test, the body for this request much reference a schema\ + \ named `File`." + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + description: Success + tags: + - fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: true + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - explode: false + in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + style: form + - explode: false + in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: requiredNotNullable + required: true + schema: + nullable: false + type: string + style: form + - explode: true + in: query + name: requiredNullable + required: true + schema: + nullable: true + type: string + style: form + - explode: true + in: query + name: notRequiredNotNullable + required: false + schema: + nullable: false + type: string + style: form + - explode: true + in: query + name: notRequiredNullable + required: false + schema: + nullable: true + type: string + style: form + responses: + "200": + description: Success + tags: + - fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + description: "" + operationId: uploadFileWithRequiredFile + 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/uploadFileWithRequiredFile_request' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + /fake/health: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + description: The instance started successfully + summary: Health check endpoint + tags: + - fake + /fake/array-of-enums: + get: + operationId: getArrayOfEnums + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ArrayOfEnums' + description: Got named array of enums + summary: Array of Enums + tags: + - fake + /country: + post: + operationId: getCountry + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/getCountry_request' + responses: + "200": + description: OK + /test: + get: + operationId: Test + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/notificationtest-getElements-v1-Response-mPayload' + description: Successful response + summary: Retrieve an existing Notificationtest's Elements +components: + requestBodies: + UserArray: + content: + application/json: + examples: + simple-list: + description: Should not get into code examples + summary: Simple list example + value: + - username: foo + - username: bar + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + 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: + RolesReport: + description: Roles report + items: + $ref: '#/components/schemas/RolesReportsHash' + type: array + RolesReportsHash: + description: Role report Hash + example: + role: + name: name + role_uuid: 046b6c7f-0b8a-43b9-b35d-6489e6daee91 + properties: + role_uuid: + format: uuid + type: string + role: + $ref: '#/components/schemas/RolesReportsHash_role' + type: object + Foo: + example: + bar: bar + properties: + bar: + default: bar + type: string + type: object + Bar: + default: bar + type: string + Order: + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2020-02-02T20:20:20.000222Z + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + example: 2020-02-02T20:20:20.000222Z + format: date-time + type: string + status: + $ref: '#/components/schemas/Order_status' + complete: + default: false + type: boolean + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + objectWithNoDeclaredPropsNullable: "{}" + phone: phone + objectWithNoDeclaredProps: "{}" + id: 0 + anyTypePropNullable: "" + email: email + anyTypeProp: "" + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + objectWithNoDeclaredProps: + description: test code generation for objects Value must be a map of strings + to values. It cannot be the 'null' value. + type: object + objectWithNoDeclaredPropsNullable: + description: test code generation for nullable objects. Value must be a + map of strings to values or the 'null' value. + nullable: true + type: object + anyTypeProp: + description: "test code generation for any type Here the 'type' attribute\ + \ is not specified, which means the value can be anything, including the\ + \ null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389" + anyTypePropNullable: + description: "test code generation for any type Here the 'type' attribute\ + \ is not specified, which means the value can be anything, including the\ + \ null value, string, number, boolean, array or object. The 'nullable'\ + \ attribute does not change the allowed values." + nullable: true + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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: + $ref: '#/components/schemas/Pet_status' + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + lock: + type: string + abstract: + nullable: true + type: string + unsafe: + type: string + required: + - abstract + - lock + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - properties: + breed: + type: string + type: object + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - properties: + declawed: + type: boolean + type: object + Address: + additionalProperties: + type: integer + type: object + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 100 + minimum: 10 + multipleOf: 2 + type: integer + int32: + format: int32 + maximum: 200 + minimum: 20 + type: integer + unsigned_integer: + format: int32 + maximum: 200 + minimum: 20 + type: integer + x-unsigned: true + int64: + format: int64 + type: integer + unsigned_long: + format: int64 + type: integer + x-unsigned: true + number: + maximum: 543.2 + minimum: 32.1 + multipleOf: 32.5 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + decimal: + format: number + type: string + string: + pattern: "/[a-z]/i" + type: string + byte: + format: byte + type: string + binary: + format: binary + type: string + date: + example: 2020-02-02 + format: date + type: string + dateTime: + example: 2007-12-03T10:15:30+01:00 + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + pattern: "^\\d{10}$" + type: string + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one + to three digits following i.e. Image_01. + pattern: "/^image_\\d{1,3}$/i" + type: string + pattern_with_backslash: + description: None + pattern: "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\\ + /([0-9]|[1-2][0-9]|3[0-2]))$" + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Outer_Enum_Test: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + type: string + Enum_Test: + properties: + enum_string: + $ref: '#/components/schemas/Enum_Test_enum_string' + enum_string_required: + $ref: '#/components/schemas/Enum_Test_enum_string' + enum_integer: + $ref: '#/components/schemas/Enum_Test_enum_integer' + enum_integer_only: + $ref: '#/components/schemas/Enum_Test_enum_integer_only' + enum_number: + $ref: '#/components/schemas/testEnumParameters_enum_query_double_parameter' + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_property: + additionalProperties: + type: string + type: object + map_of_map_property: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + anytype_1: {} + map_with_undeclared_properties_anytype_1: + type: object + map_with_undeclared_properties_anytype_2: + properties: {} + type: object + map_with_undeclared_properties_anytype_3: + additionalProperties: true + type: object + empty_map: + additionalProperties: false + description: "an object with no declared properties and no undeclared properties,\ + \ hence it's an empty map." + type: object + map_with_undeclared_properties_string: + additionalProperties: + type: string + type: object + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid_with_pattern: + format: uuid + pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" + type: string + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + $ref: '#/components/schemas/MapTest_map_of_enum_string_value' + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + x-cls-compliant: true + x-com-visible: true + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + $ref: '#/components/schemas/EnumArrays_just_symbol' + array_enum: + items: + $ref: '#/components/schemas/EnumArrays_array_enum_inner' + type: array + type: object + FreeFormObject: + additionalProperties: true + description: A schema consisting only of additional properties + type: object + MapOfString: + additionalProperties: + type: string + description: A schema consisting only of additional properties of type string + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + nullable: true + type: string + OuterEnumInteger: + enum: + - 0 + - 1 + - 2 + type: integer + OuterEnumDefaultValue: + default: placed + enum: + - placed + - approved + - delivered + type: string + OuterEnumIntegerDefaultValue: + default: 0 + enum: + - 0 + - 1 + - 2 + type: integer + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + _special_model.name_: + properties: + $special[property.name]: + format: int64 + type: integer + _special_model.name_: + type: string + xml: + name: "$special[model.name]" + HealthCheckResult: + description: Just a string to inform instance is up and running. Make it nullable + in hope to get it as pointer in generated model. + example: + NullableMessage: NullableMessage + properties: + NullableMessage: + nullable: true + type: string + type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_integer' + required_notnullable_enum_integer: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_integer' + notrequired_nullable_enum_integer: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_integer' + notrequired_notnullable_enum_integer: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_integer' + required_nullable_enum_integer_only: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_integer_only' + required_notnullable_enum_integer_only: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_integer_only' + notrequired_nullable_enum_integer_only: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_integer_only' + notrequired_notnullable_enum_integer_only: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_integer_only' + required_notnullable_enum_string: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_string' + required_nullable_enum_string: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_string' + notrequired_nullable_enum_string: + $ref: '#/components/schemas/RequiredClass_required_nullable_enum_string' + notrequired_notnullable_enum_string: + $ref: '#/components/schemas/RequiredClass_required_notnullable_enum_string' + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object + NullableClass: + additionalProperties: + nullable: true + type: object + properties: + integer_prop: + nullable: true + type: integer + number_prop: + nullable: true + type: number + boolean_prop: + nullable: true + type: boolean + string_prop: + nullable: true + type: string + date_prop: + format: date + nullable: true + type: string + datetime_prop: + format: date-time + nullable: true + type: string + array_nullable_prop: + items: + type: object + nullable: true + type: array + array_and_items_nullable_prop: + items: + nullable: true + type: object + nullable: true + type: array + array_items_nullable: + items: + nullable: true + type: object + type: array + object_nullable_prop: + additionalProperties: + type: object + nullable: true + type: object + object_and_items_nullable_prop: + additionalProperties: + nullable: true + type: object + nullable: true + type: object + object_items_nullable: + additionalProperties: + nullable: true + type: object + type: object + type: object + fruit: + additionalProperties: false + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + apple: + nullable: true + properties: + cultivar: + pattern: "^[a-zA-Z\\s]*$" + type: string + origin: + pattern: "/^[A-Z\\s]*$/i" + type: string + color_code: + pattern: "^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$" + type: string + type: object + banana: + properties: + lengthCm: + type: number + type: object + mammal: + discriminator: + propertyName: className + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + - $ref: '#/components/schemas/Pig' + whale: + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + type: object + zebra: + additionalProperties: true + properties: + type: + $ref: '#/components/schemas/zebra_type' + className: + type: string + required: + - className + type: object + Pig: + discriminator: + propertyName: className + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + BasquePig: + properties: + className: + type: string + required: + - className + type: object + DanishPig: + properties: + className: + type: string + required: + - className + type: object + gmFruit: + additionalProperties: false + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + fruitReq: + additionalProperties: false + nullable: true + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + appleReq: + additionalProperties: false + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + type: object + bananaReq: + additionalProperties: false + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + type: object + Drawing: + additionalProperties: + $ref: '#/components/schemas/fruit' + properties: + mainShape: + $ref: '#/components/schemas/Shape' + shapeOrNull: + $ref: '#/components/schemas/ShapeOrNull' + nullableShape: + $ref: '#/components/schemas/NullableShape' + shapes: + items: + $ref: '#/components/schemas/Shape' + type: array + type: object + Shape: + discriminator: + propertyName: shapeType + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + ShapeOrNull: + description: The value may be a shape or the 'null' value. This is introduced + in OAS schema >= 3.1. + discriminator: + propertyName: shapeType + nullable: true + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + NullableShape: + description: The value may be a shape or the 'null' value. The 'nullable' attribute + was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema + >= 3.1. + discriminator: + propertyName: shapeType + nullable: true + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + discriminator: + propertyName: triangleType + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + additionalProperties: false + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + discriminator: + propertyName: quadrilateralType + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + GrandparentAnimal: + discriminator: + propertyName: pet_type + properties: + pet_type: + type: string + required: + - pet_type + type: object + ParentPet: + allOf: + - $ref: '#/components/schemas/GrandparentAnimal' + type: object + ChildCat: + allOf: + - $ref: '#/components/schemas/ParentPet' + - properties: + name: + type: string + pet_type: + $ref: '#/components/schemas/ChildCat_allOf_pet_type' + required: + - pet_type + type: object + ArrayOfEnums: + items: + $ref: '#/components/schemas/OuterEnum' + type: array + DateTimeTest: + default: 2010-01-01T10:10:10.000111+01:00 + example: 2010-01-01T10:10:10.000111+01:00 + format: date-time + type: string + DeprecatedObject: + deprecated: true + properties: + name: + type: string + type: object + ObjectWithDeprecatedFields: + properties: + uuid: + type: string + id: + deprecated: true + type: number + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + deprecated: true + items: + $ref: '#/components/schemas/Bar' + type: array + type: object + PolymorphicProperty: + oneOf: + - type: boolean + - type: string + - type: object + - items: + $ref: '#/components/schemas/StringArrayItem' + type: array + StringArrayItem: + format: string + type: string + Activity: + description: test map of maps + properties: + activity_outputs: + additionalProperties: + $ref: '#/components/schemas/ActivityOutputRepresentation' + type: object + type: object + ActivityOutputRepresentation: + items: + $ref: '#/components/schemas/ActivityOutputElementRepresentation' + type: array + ActivityOutputElementRepresentation: + properties: + prop1: + type: string + prop2: + type: object + type: object + NullableGuidClass: + properties: + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + type: object + DateOnlyClass: + properties: + dateOnlyProperty: + example: 2017-07-21 + format: date + type: string + type: object + TestCollectionEndingWithWordListObject: + properties: + TestCollectionEndingWithWordList: + items: + $ref: '#/components/schemas/TestCollectionEndingWithWordList' + type: array + type: object + TestCollectionEndingWithWordList: + properties: + value: + type: string + type: object + LiteralStringClass: + properties: + escapedLiteralString: + default: C:\\Users\\username + type: string + unescapedLiteralString: + default: C:\Users\username + type: string + type: object + OneOfString: + oneOf: + - pattern: ^a + type: string + - pattern: ^b + type: string + ZeroBasedEnum: + enum: + - unknown + - notUnknown + type: string + ZeroBasedEnumClass: + properties: + ZeroBasedEnum: + $ref: '#/components/schemas/ZeroBasedEnumClass_ZeroBasedEnum' + type: object + Custom-Variableobject-Response: + additionalProperties: true + description: A Variable object without predefined property names + type: object + Field-pkiNotificationtestID: + type: integer + notificationtest-getElements-v1-Response-mPayload: + example: + a_objVariableobject: + - null + - null + pkiNotificationtestID: 0 + properties: + pkiNotificationtestID: + type: integer + a_objVariableobject: + items: + $ref: '#/components/schemas/Custom-Variableobject-Response' + type: array + required: + - a_objVariableobject + - pkiNotificationtestID + type: object + MixLog: + properties: + id: + format: uuid + type: string + description: + type: string + mixDate: + format: date-time + type: string + shopId: + format: uuid + type: string + totalPrice: + format: float + nullable: true + type: number + totalRecalculations: + format: int32 + type: integer + totalOverPoors: + format: int32 + type: integer + totalSkips: + format: int32 + type: integer + totalUnderPours: + format: int32 + type: integer + formulaVersionDate: + format: date-time + type: string + someCode: + description: SomeCode is only required for color mixes + nullable: true + type: string + batchNumber: + type: string + brandCode: + description: BrandCode is only required for non-color mixes + type: string + brandId: + description: BrandId is only required for color mixes + type: string + brandName: + description: BrandName is only required for color mixes + type: string + categoryCode: + description: CategoryCode is not used anymore + type: string + color: + description: Color is only required for color mixes + type: string + colorDescription: + type: string + comment: + type: string + commercialProductCode: + type: string + productLineCode: + description: ProductLineCode is only required for color mixes + type: string + country: + type: string + createdBy: + type: string + createdByFirstName: + type: string + createdByLastName: + type: string + deltaECalculationRepaired: + type: string + deltaECalculationSprayout: + type: string + ownColorVariantNumber: + format: int32 + nullable: true + type: integer + primerProductId: + type: string + productId: + description: ProductId is only required for color mixes + type: string + productName: + description: ProductName is only required for color mixes + type: string + selectedVersionIndex: + format: int32 + type: integer + required: + - description + - formulaVersionDate + - id + - mixDate + - totalOverPoors + - totalRecalculations + - totalSkips + - totalUnderPours + type: object + uuid: + format: uuid + type: string + _foo_get_default_response: + example: + string: + bar: bar + properties: + string: + $ref: '#/components/schemas/Foo' + type: object + findPetsByStatus_status_parameter_inner: + default: available + enum: + - available + - pending + - sold + type: string + 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 + testEnumParameters_request_enum_form_string_array_inner: + default: $ + enum: + - '>' + - $ + type: string + testEnumParameters_request_enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + testEnumParameters_request: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + $ref: '#/components/schemas/testEnumParameters_request_enum_form_string_array_inner' + type: array + enum_form_string: + $ref: '#/components/schemas/testEnumParameters_request_enum_form_string' + type: object + testEnumParameters_enum_header_string_parameter: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + testEnumParameters_enum_query_integer_parameter: + enum: + - 1 + - -2 + format: int32 + type: integer + testEnumParameters_enum_query_double_parameter: + enum: + - 1.1 + - -1.2 + format: double + type: number + testEndpointParameters_request: + properties: + integer: + description: None + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: "/[a-z]/i" + type: string + pattern_without_delimiter: + description: None + pattern: "^[A-Z].*" + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + default: 2010-02-01T10:20:10.11111+01:00 + description: None + example: 2020-02-02T20:20:20.22222Z + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + type: object + testJsonFormData_request: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + type: object + testInlineFreeformAdditionalProperties_request: + additionalProperties: true + properties: + someProperty: + type: string + type: object + uploadFileWithRequiredFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + type: object + getCountry_request: + allOf: + - properties: + country: + type: string + required: + - country + type: object + RolesReportsHash_role: + example: + name: name + properties: + name: + type: string + type: object + Order_status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + Pet_status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + Enum_Test_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + type: string + Enum_Test_enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + Enum_Test_enum_integer_only: + enum: + - 2 + - -2 + type: integer + MapTest_map_of_enum_string_value: + enum: + - UPPER + - lower + type: string + EnumArrays_just_symbol: + enum: + - '>=' + - $ + type: string + EnumArrays_array_enum_inner: + enum: + - fish + - crab + type: string + RequiredClass_required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + RequiredClass_required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + RequiredClass_required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + RequiredClass_required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + RequiredClass_required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + RequiredClass_required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + zebra_type: + enum: + - plains + - mountain + - grevys + type: string + ChildCat_allOf_pet_type: + default: ChildCat + enum: + - ChildCat + type: string + x-enum-as-string: true + ZeroBasedEnumClass_ZeroBasedEnum: + enum: + - unknown + - notUnknown + type: string + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http + bearer_test: + bearerFormat: JWT + scheme: bearer + type: http + http_signature_test: + scheme: signature + type: http + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/AnotherFakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/AnotherFakeApi.md new file mode 100644 index 000000000000..369488986579 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/AnotherFakeApi.md @@ -0,0 +1,99 @@ +# Org.OpenAPITools.Api.AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**Call123TestSpecialTags**](AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags | + + +# **Call123TestSpecialTags** +> ModelClient Call123TestSpecialTags (ModelClient modelClient) + +To test special tags + +To test special tags and operation ID starting with number + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class Call123TestSpecialTagsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new AnotherFakeApi(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test special tags + ModelClient result = apiInstance.Call123TestSpecialTags(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the Call123TestSpecialTagsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test special tags + ApiResponse response = apiInstance.Call123TestSpecialTagsWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTagsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..0bdfd6af3474 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/DefaultApi.md @@ -0,0 +1,429 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | +| [**Hello**](DefaultApi.md#hello) | **GET** /hello | Hello | +| [**RolesReportGet**](DefaultApi.md#rolesreportget) | **GET** /roles/report | | +| [**Test**](DefaultApi.md#test) | **GET** /test | Retrieve an existing Notificationtest's Elements | + + +# **FooGet** +> FooGetDefaultResponse FooGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FooGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + FooGetDefaultResponse result = apiInstance.FooGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.FooGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FooGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FooGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.FooGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**FooGetDefaultResponse**](FooGetDefaultResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **Hello** +> List<Guid> Hello () + +Hello + +Hello + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class HelloExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + // Hello + List result = apiInstance.Hello(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.Hello: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the HelloWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Hello + ApiResponse> response = apiInstance.HelloWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.HelloWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**List** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | UUIDs | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **RolesReportGet** +> List<List<RolesReportsHash>> RolesReportGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class RolesReportGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + List> result = apiInstance.RolesReportGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.RolesReportGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the RolesReportGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse>> response = apiInstance.RolesReportGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.RolesReportGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**List>** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | returns report | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **Test** +> NotificationtestGetElementsV1ResponseMPayload Test () + +Retrieve an existing Notificationtest's Elements + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + // Retrieve an existing Notificationtest's Elements + NotificationtestGetElementsV1ResponseMPayload result = apiInstance.Test(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.Test: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Retrieve an existing Notificationtest's Elements + ApiResponse response = apiInstance.TestWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.TestWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**NotificationtestGetElementsV1ResponseMPayload**](NotificationtestGetElementsV1ResponseMPayload.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful response | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md new file mode 100644 index 000000000000..d87f500d56c8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md @@ -0,0 +1,1660 @@ +# Org.OpenAPITools.Api.FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**FakeHealthGet**](FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint | +| [**FakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | | +| [**FakeOuterCompositeSerialize**](FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | | +| [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | +| [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | +| [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | +| [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | +| [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | +| [**TestClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model | +| [**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 | +| [**TestEnumParameters**](FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters | +| [**TestGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | +| [**TestInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | +| [**TestInlineFreeformAdditionalProperties**](FakeApi.md#testinlinefreeformadditionalproperties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties | +| [**TestJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**TestQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | | +| [**TestStringMapReference**](FakeApi.md#teststringmapreference) | **POST** /fake/stringMap-reference | test referenced string map | + + +# **FakeHealthGet** +> HealthCheckResult FakeHealthGet () + +Health check endpoint + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeHealthGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Health check endpoint + HealthCheckResult result = apiInstance.FakeHealthGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeHealthGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeHealthGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Health check endpoint + ApiResponse response = apiInstance.FakeHealthGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeHealthGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**HealthCheckResult**](HealthCheckResult.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The instance started successfully | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterBooleanSerialize** +> bool FakeOuterBooleanSerialize (bool body = null) + + + +Test serialization of outer boolean types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterBooleanSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var body = true; // bool | Input boolean as post body (optional) + + try + { + bool result = apiInstance.FakeOuterBooleanSerialize(body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterBooleanSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterBooleanSerializeWithHttpInfo(body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **body** | **bool** | Input boolean as post body | [optional] | + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output boolean | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterCompositeSerialize** +> OuterComposite FakeOuterCompositeSerialize (OuterComposite outerComposite = null) + + + +Test serialization of object with outer number type + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterCompositeSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var outerComposite = new OuterComposite(); // OuterComposite | Input composite as post body (optional) + + try + { + OuterComposite result = apiInstance.FakeOuterCompositeSerialize(outerComposite); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterCompositeSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterCompositeSerializeWithHttpInfo(outerComposite); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **outerComposite** | [**OuterComposite**](OuterComposite.md) | Input composite as post body | [optional] | + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output composite | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterNumberSerialize** +> decimal FakeOuterNumberSerialize (decimal body = null) + + + +Test serialization of outer number types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterNumberSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var body = 8.14D; // decimal | Input number as post body (optional) + + try + { + decimal result = apiInstance.FakeOuterNumberSerialize(body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterNumberSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterNumberSerializeWithHttpInfo(body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **body** | **decimal** | Input number as post body | [optional] | + +### Return type + +**decimal** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output number | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterStringSerialize** +> string FakeOuterStringSerialize (Guid requiredStringUuid, string body = null) + + + +Test serialization of outer string types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterStringSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requiredStringUuid = "requiredStringUuid_example"; // Guid | Required UUID String + var body = "body_example"; // string | Input string as post body (optional) + + try + { + string result = apiInstance.FakeOuterStringSerialize(requiredStringUuid, body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterStringSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterStringSerializeWithHttpInfo(requiredStringUuid, body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredStringUuid** | **Guid** | Required UUID String | | +| **body** | **string** | Input string as post body | [optional] | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output string | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetArrayOfEnums** +> List<OuterEnum> GetArrayOfEnums () + +Array of Enums + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetArrayOfEnumsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Array of Enums + List result = apiInstance.GetArrayOfEnums(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetArrayOfEnums: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetArrayOfEnumsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Array of Enums + ApiResponse> response = apiInstance.GetArrayOfEnumsWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetArrayOfEnumsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**List<OuterEnum>**](OuterEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got named array of enums | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestAdditionalPropertiesReference** +> void TestAdditionalPropertiesReference (Dictionary requestBody) + +test referenced additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestAdditionalPropertiesReferenceExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test referenced additionalProperties + apiInstance.TestAdditionalPropertiesReference(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestAdditionalPropertiesReference: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestAdditionalPropertiesReferenceWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test referenced additionalProperties + apiInstance.TestAdditionalPropertiesReferenceWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestAdditionalPropertiesReferenceWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, Object>**](Object.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestBodyWithFileSchema** +> void TestBodyWithFileSchema (FileSchemaTestClass fileSchemaTestClass) + + + +For this test, the body for this request much reference a schema named `File`. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestBodyWithFileSchemaExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var fileSchemaTestClass = new FileSchemaTestClass(); // FileSchemaTestClass | + + try + { + apiInstance.TestBodyWithFileSchema(fileSchemaTestClass); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchema: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestBodyWithFileSchemaWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchemaWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **fileSchemaTestClass** | [**FileSchemaTestClass**](FileSchemaTestClass.md) | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestBodyWithQueryParams** +> void TestBodyWithQueryParams (User user, string query) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestBodyWithQueryParamsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var user = new User(); // User | + var query = "query_example"; // string | + + try + { + apiInstance.TestBodyWithQueryParams(user, query); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParams: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestBodyWithQueryParamsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestBodyWithQueryParamsWithHttpInfo(user, query); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParamsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | | | +| **query** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestClientModel** +> ModelClient TestClientModel (ModelClient modelClient) + +To test \"client\" model + +To test \"client\" model + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestClientModelExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test \"client\" model + ModelClient result = apiInstance.TestClientModel(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestClientModelWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test \"client\" model + ApiResponse response = apiInstance.TestClientModelWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestClientModelWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestEndpointParameters** +> void TestEndpointParameters (byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime date = null, System.IO.Stream binary = null, float varFloat = null, int integer = null, int int32 = null, long int64 = null, string varString = null, string password = null, string callback = null, DateTime dateTime = null) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestEndpointParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure HTTP basic authorization: http_basic_test + config.Username = "YOUR_USERNAME"; + config.Password = "YOUR_PASSWORD"; + + var apiInstance = new FakeApi(config); + var varByte = System.Text.Encoding.ASCII.GetBytes("BYTE_ARRAY_DATA_HERE"); // byte[] | None + var number = 8.14D; // decimal | None + var varDouble = 1.2D; // double | None + var patternWithoutDelimiter = "patternWithoutDelimiter_example"; // string | None + var date = DateTime.Parse("2013-10-20"); // DateTime | None (optional) + var binary = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | None (optional) + var varFloat = 3.4F; // float | None (optional) + var integer = 56; // int | None (optional) + var int32 = 56; // int | None (optional) + var int64 = 789L; // long | None (optional) + var varString = "varString_example"; // string | None (optional) + var password = "password_example"; // string | None (optional) + var callback = "callback_example"; // string | None (optional) + var dateTime = DateTime.Parse(""2010-02-01T10:20:10.111110+01:00""); // DateTime | None (optional) (default to "2010-02-01T10:20:10.111110+01:00") + + try + { + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + apiInstance.TestEndpointParameters(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestEndpointParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + apiInstance.TestEndpointParametersWithHttpInfo(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestEndpointParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **varByte** | **byte[]** | None | | +| **number** | **decimal** | None | | +| **varDouble** | **double** | None | | +| **patternWithoutDelimiter** | **string** | None | | +| **date** | **DateTime** | None | [optional] | +| **binary** | **System.IO.Stream****System.IO.Stream** | None | [optional] | +| **varFloat** | **float** | None | [optional] | +| **integer** | **int** | None | [optional] | +| **int32** | **int** | None | [optional] | +| **int64** | **long** | None | [optional] | +| **varString** | **string** | None | [optional] | +| **password** | **string** | None | [optional] | +| **callback** | **string** | None | [optional] | +| **dateTime** | **DateTime** | None | [optional] [default to "2010-02-01T10:20:10.111110+01:00"] | + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestEnumParameters** +> void TestEnumParameters (List enumHeaderStringArray = null, List enumQueryStringArray = null, List enumFormStringArray = null, TestEnumParametersEnumHeaderStringParameter enumHeaderString = null, TestEnumParametersEnumHeaderStringParameter enumQueryString = null, TestEnumParametersEnumQueryDoubleParameter enumQueryDouble = null, TestEnumParametersEnumQueryIntegerParameter enumQueryInteger = null, TestEnumParametersRequestEnumFormString enumFormString = null) + +To test enum parameters + +To test enum parameters + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestEnumParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var enumHeaderStringArray = new List(); // List | Header parameter enum test (string array) (optional) + var enumQueryStringArray = new List(); // List | Query parameter enum test (string array) (optional) + var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) + var enumHeaderString = (TestEnumParametersEnumHeaderStringParameter) "_abc"; // TestEnumParametersEnumHeaderStringParameter | Header parameter enum test (string) (optional) + var enumQueryString = (TestEnumParametersEnumHeaderStringParameter) "_abc"; // TestEnumParametersEnumHeaderStringParameter | Query parameter enum test (string) (optional) + var enumQueryDouble = (TestEnumParametersEnumQueryDoubleParameter) "1.1"; // TestEnumParametersEnumQueryDoubleParameter | Query parameter enum test (double) (optional) + var enumQueryInteger = (TestEnumParametersEnumQueryIntegerParameter) "1"; // TestEnumParametersEnumQueryIntegerParameter | Query parameter enum test (double) (optional) + var enumFormString = (TestEnumParametersRequestEnumFormString) "_abc"; // TestEnumParametersRequestEnumFormString | (optional) + + try + { + // To test enum parameters + apiInstance.TestEnumParameters(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestEnumParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestEnumParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test enum parameters + apiInstance.TestEnumParametersWithHttpInfo(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestEnumParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **enumHeaderStringArray** | [**List<TestEnumParametersRequestEnumFormStringArrayInner>**](TestEnumParametersRequestEnumFormStringArrayInner.md) | Header parameter enum test (string array) | [optional] | +| **enumQueryStringArray** | [**List<TestEnumParametersRequestEnumFormStringArrayInner>**](TestEnumParametersRequestEnumFormStringArrayInner.md) | Query parameter enum test (string array) | [optional] | +| **enumFormStringArray** | [**List<TestEnumParametersRequestEnumFormStringArrayInner>**](TestEnumParametersRequestEnumFormStringArrayInner.md) | Form parameter enum test (string array) | [optional] | +| **enumHeaderString** | **TestEnumParametersEnumHeaderStringParameter** | Header parameter enum test (string) | [optional] | +| **enumQueryString** | **TestEnumParametersEnumHeaderStringParameter** | Query parameter enum test (string) | [optional] | +| **enumQueryDouble** | **TestEnumParametersEnumQueryDoubleParameter** | Query parameter enum test (double) | [optional] | +| **enumQueryInteger** | **TestEnumParametersEnumQueryIntegerParameter** | Query parameter enum test (double) | [optional] | +| **enumFormString** | **TestEnumParametersRequestEnumFormString** | | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid request | - | +| **404** | Not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestGroupParameters** +> void TestGroupParameters (bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool booleanGroup = null, int stringGroup = null, long int64Group = null) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestGroupParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure Bearer token for authorization: bearer_test + config.AccessToken = "YOUR_BEARER_TOKEN"; + + var apiInstance = new FakeApi(config); + var requiredBooleanGroup = true; // bool | Required Boolean in group parameters + var requiredStringGroup = 56; // int | Required String in group parameters + var requiredInt64Group = 789L; // long | Required Integer in group parameters + var booleanGroup = true; // bool | Boolean in group parameters (optional) + var stringGroup = 56; // int | String in group parameters (optional) + var int64Group = 789L; // long | Integer in group parameters (optional) + + try + { + // Fake endpoint to test group parameters (optional) + apiInstance.TestGroupParameters(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestGroupParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestGroupParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Fake endpoint to test group parameters (optional) + apiInstance.TestGroupParametersWithHttpInfo(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestGroupParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredBooleanGroup** | **bool** | Required Boolean in group parameters | | +| **requiredStringGroup** | **int** | Required String in group parameters | | +| **requiredInt64Group** | **long** | Required Integer in group parameters | | +| **booleanGroup** | **bool** | Boolean in group parameters | [optional] | +| **stringGroup** | **int** | String in group parameters | [optional] | +| **int64Group** | **long** | Integer in group parameters | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[bearer_test](../README.md#bearer_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Something wrong | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestInlineAdditionalProperties** +> void TestInlineAdditionalProperties (Dictionary requestBody) + +test inline additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestInlineAdditionalPropertiesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test inline additionalProperties + apiInstance.TestInlineAdditionalProperties(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestInlineAdditionalProperties: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestInlineAdditionalPropertiesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test inline additionalProperties + apiInstance.TestInlineAdditionalPropertiesWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestInlineAdditionalPropertiesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, string>**](string.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestInlineFreeformAdditionalProperties** +> void TestInlineFreeformAdditionalProperties (TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + +test inline free-form additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestInlineFreeformAdditionalPropertiesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var testInlineFreeformAdditionalPropertiesRequest = new TestInlineFreeformAdditionalPropertiesRequest(); // TestInlineFreeformAdditionalPropertiesRequest | request body + + try + { + // test inline free-form additionalProperties + apiInstance.TestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestInlineFreeformAdditionalProperties: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestInlineFreeformAdditionalPropertiesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test inline free-form additionalProperties + apiInstance.TestInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestInlineFreeformAdditionalPropertiesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **testInlineFreeformAdditionalPropertiesRequest** | [**TestInlineFreeformAdditionalPropertiesRequest**](TestInlineFreeformAdditionalPropertiesRequest.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestJsonFormData** +> void TestJsonFormData (string param, string param2) + +test json serialization of form data + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestJsonFormDataExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var param = "param_example"; // string | field1 + var param2 = "param2_example"; // string | field2 + + try + { + // test json serialization of form data + apiInstance.TestJsonFormData(param, param2); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestJsonFormData: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestJsonFormDataWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test json serialization of form data + apiInstance.TestJsonFormDataWithHttpInfo(param, param2); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestJsonFormDataWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **param** | **string** | field1 | | +| **param2** | **string** | field2 | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestQueryParameterCollectionFormat** +> void TestQueryParameterCollectionFormat (List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, string notRequiredNotNullable = null, string notRequiredNullable = null) + + + +To test the collection format in query parameters + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestQueryParameterCollectionFormatExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var pipe = new List(); // List | + var ioutil = new List(); // List | + var http = new List(); // List | + var url = new List(); // List | + var context = new List(); // List | + var requiredNotNullable = "requiredNotNullable_example"; // string | + var requiredNullable = "requiredNullable_example"; // string | + var notRequiredNotNullable = "notRequiredNotNullable_example"; // string | (optional) + var notRequiredNullable = "notRequiredNullable_example"; // string | (optional) + + try + { + apiInstance.TestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestQueryParameterCollectionFormat: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestQueryParameterCollectionFormatWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestQueryParameterCollectionFormatWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pipe** | [**List<string>**](string.md) | | | +| **ioutil** | [**List<string>**](string.md) | | | +| **http** | [**List<string>**](string.md) | | | +| **url** | [**List<string>**](string.md) | | | +| **context** | [**List<string>**](string.md) | | | +| **requiredNotNullable** | **string** | | | +| **requiredNullable** | **string** | | | +| **notRequiredNotNullable** | **string** | | [optional] | +| **notRequiredNullable** | **string** | | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestStringMapReference** +> void TestStringMapReference (Dictionary requestBody) + +test referenced string map + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestStringMapReferenceExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test referenced string map + apiInstance.TestStringMapReference(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestStringMapReference: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestStringMapReferenceWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test referenced string map + apiInstance.TestStringMapReferenceWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestStringMapReferenceWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, string>**](string.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeClassnameTags123Api.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..dfe1adefd0a7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeClassnameTags123Api.md @@ -0,0 +1,104 @@ +# Org.OpenAPITools.Api.FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**TestClassname**](FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case | + + +# **TestClassname** +> ModelClient TestClassname (ModelClient modelClient) + +To test class name in snake case + +To test class name in snake case + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestClassnameExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key_query + config.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key_query", "Bearer"); + + var apiInstance = new FakeClassnameTags123Api(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test class name in snake case + ModelClient result = apiInstance.TestClassname(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassname: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestClassnameWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test class name in snake case + ApiResponse response = apiInstance.TestClassnameWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassnameWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md new file mode 100644 index 000000000000..862c66f0beee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/PetApi.md @@ -0,0 +1,860 @@ +# Org.OpenAPITools.Api.PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**AddPet**](PetApi.md#addpet) | **POST** /pet | Add a new pet to the store | +| [**DeletePet**](PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**FindPetsByStatus**](PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**FindPetsByTags**](PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**GetPetById**](PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID | +| [**UpdatePet**](PetApi.md#updatepet) | **PUT** /pet | Update an existing pet | +| [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | + + +# **AddPet** +> void AddPet (Pet pet) + +Add a new pet to the store + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class AddPetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var pet = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Add a new pet to the store + apiInstance.AddPet(pet); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.AddPet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the AddPetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Add a new pet to the store + apiInstance.AddPetWithHttpInfo(pet); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.AddPetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **DeletePet** +> void DeletePet (long petId, string apiKey = null) + +Deletes a pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeletePetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | Pet id to delete + var apiKey = "apiKey_example"; // string | (optional) + + try + { + // Deletes a pet + apiInstance.DeletePet(petId, apiKey); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeletePetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Deletes a pet + apiInstance.DeletePetWithHttpInfo(petId, apiKey); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.DeletePetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | Pet id to delete | | +| **apiKey** | **string** | | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FindPetsByStatus** +> List<Pet> FindPetsByStatus (List status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FindPetsByStatusExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var status = new List(); // List | Status values that need to be considered for filter + + try + { + // Finds Pets by status + List result = apiInstance.FindPetsByStatus(status); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FindPetsByStatusWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Finds Pets by status + ApiResponse> response = apiInstance.FindPetsByStatusWithHttpInfo(status); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.FindPetsByStatusWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **status** | [**List<FindPetsByStatusStatusParameterInner>**](FindPetsByStatusStatusParameterInner.md) | Status values that need to be considered for filter | | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FindPetsByTags** +> List<Pet> FindPetsByTags (List tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FindPetsByTagsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var tags = new List(); // List | Tags to filter by + + try + { + // Finds Pets by tags + List result = apiInstance.FindPetsByTags(tags); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FindPetsByTagsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Finds Pets by tags + ApiResponse> response = apiInstance.FindPetsByTagsWithHttpInfo(tags); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.FindPetsByTagsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **tags** | [**List<string>**](string.md) | Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetPetById** +> Pet GetPetById (long petId) + +Find pet by ID + +Returns a single pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetPetByIdExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key + config.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key", "Bearer"); + // Configure API key authorization: api_key_query + config.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key_query", "Bearer"); + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to return + + try + { + // Find pet by ID + Pet result = apiInstance.GetPetById(petId); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetPetByIdWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Find pet by ID + ApiResponse response = apiInstance.GetPetByIdWithHttpInfo(petId); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.GetPetByIdWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key), [api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdatePet** +> void UpdatePet (Pet pet) + +Update an existing pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdatePetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var pet = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Update an existing pet + apiInstance.UpdatePet(pet); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdatePetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Update an existing pet + apiInstance.UpdatePetWithHttpInfo(pet); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UpdatePetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdatePetWithForm** +> void UpdatePetWithForm (long petId, string name = null, string status = null) + +Updates a pet in the store with form data + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdatePetWithFormExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet that needs to be updated + var name = "name_example"; // string | Updated name of the pet (optional) + var status = "status_example"; // string | Updated status of the pet (optional) + + try + { + // Updates a pet in the store with form data + apiInstance.UpdatePetWithForm(petId, name, status); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdatePetWithFormWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Updates a pet in the store with form data + apiInstance.UpdatePetWithFormWithHttpInfo(petId, name, status); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UpdatePetWithFormWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet that needs to be updated | | +| **name** | **string** | Updated name of the pet | [optional] | +| **status** | **string** | Updated status of the pet | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UploadFile** +> ApiResponse UploadFile (long petId, System.IO.Stream file = null, string additionalMetadata = null) + +uploads an image + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFileExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var file = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | file to upload (optional) + var additionalMetadata = "additionalMetadata_example"; // string | Additional data to pass to server (optional) + + try + { + // uploads an image + ApiResponse result = apiInstance.UploadFile(petId, file, additionalMetadata); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFileWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an image + ApiResponse response = apiInstance.UploadFileWithHttpInfo(petId, file, additionalMetadata); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFileWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **file** | **System.IO.Stream****System.IO.Stream** | file to upload | [optional] | +| **additionalMetadata** | **string** | Additional data to pass to server | [optional] | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UploadFileWithRequiredFile** +> ApiResponse UploadFileWithRequiredFile (System.IO.Stream requiredFile, long petId, string additionalMetadata = null) + +uploads an image (required) + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFileWithRequiredFileExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var requiredFile = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | file to upload + var petId = 789L; // long | ID of pet to update + var additionalMetadata = "additionalMetadata_example"; // string | Additional data to pass to server (optional) + + try + { + // uploads an image (required) + ApiResponse result = apiInstance.UploadFileWithRequiredFile(requiredFile, petId, additionalMetadata); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFile: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFileWithRequiredFileWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an image (required) + ApiResponse response = apiInstance.UploadFileWithRequiredFileWithHttpInfo(requiredFile, petId, additionalMetadata); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFileWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredFile** | **System.IO.Stream****System.IO.Stream** | file to upload | | +| **petId** | **long** | ID of pet to update | | +| **additionalMetadata** | **string** | Additional data to pass to server | [optional] | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/StoreApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/StoreApi.md new file mode 100644 index 000000000000..4a1cd29ada7a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/StoreApi.md @@ -0,0 +1,373 @@ +# Org.OpenAPITools.Api.StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID | +| [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID | +| [**PlaceOrder**](StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet | + + +# **DeleteOrder** +> void DeleteOrder (string orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeleteOrderExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var orderId = "orderId_example"; // string | ID of the order that needs to be deleted + + try + { + // Delete purchase order by ID + apiInstance.DeleteOrder(orderId); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeleteOrderWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Delete purchase order by ID + apiInstance.DeleteOrderWithHttpInfo(orderId); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.DeleteOrderWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **orderId** | **string** | ID of the order that needs to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetInventory** +> Dictionary<string, int> GetInventory () + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetInventoryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key + config.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key", "Bearer"); + + var apiInstance = new StoreApi(config); + + try + { + // Returns pet inventories by status + Dictionary result = apiInstance.GetInventory(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetInventoryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Returns pet inventories by status + ApiResponse> response = apiInstance.GetInventoryWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.GetInventoryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**Dictionary** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetOrderById** +> Order GetOrderById (long orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetOrderByIdExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var orderId = 789L; // long | ID of pet that needs to be fetched + + try + { + // Find purchase order by ID + Order result = apiInstance.GetOrderById(orderId); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetOrderByIdWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Find purchase order by ID + ApiResponse response = apiInstance.GetOrderByIdWithHttpInfo(orderId); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.GetOrderByIdWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **orderId** | **long** | ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **PlaceOrder** +> Order PlaceOrder (Order order) + +Place an order for a pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class PlaceOrderExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var order = new Order(); // Order | order placed for purchasing the pet + + try + { + // Place an order for a pet + Order result = apiInstance.PlaceOrder(order); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the PlaceOrderWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Place an order for a pet + ApiResponse response = apiInstance.PlaceOrderWithHttpInfo(order); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.PlaceOrderWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **order** | [**Order**](Order.md) | order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/UserApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/UserApi.md new file mode 100644 index 000000000000..ee189c866ec5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/UserApi.md @@ -0,0 +1,715 @@ +# Org.OpenAPITools.Api.UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user | +| [**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user | +| [**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name | +| [**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system | +| [**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session | +| [**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user | + + +# **CreateUser** +> void CreateUser (User user) + +Create user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new User(); // User | Created user object + + try + { + // Create user + apiInstance.CreateUser(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Create user + apiInstance.CreateUserWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | Created user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **CreateUsersWithArrayInput** +> void CreateUsersWithArrayInput (List user) + +Creates list of users with given input array + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUsersWithArrayInputExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInput(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUsersWithArrayInputWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInputWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInputWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**List<User>**](User.md) | List of user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **CreateUsersWithListInput** +> void CreateUsersWithListInput (List user) + +Creates list of users with given input array + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUsersWithListInputExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithListInput(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUsersWithListInputWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Creates list of users with given input array + apiInstance.CreateUsersWithListInputWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUsersWithListInputWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**List<User>**](User.md) | List of user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **DeleteUser** +> void DeleteUser (string username) + +Delete user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeleteUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The name that needs to be deleted + + try + { + // Delete user + apiInstance.DeleteUser(username); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeleteUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Delete user + apiInstance.DeleteUserWithHttpInfo(username); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.DeleteUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The name that needs to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetUserByName** +> User GetUserByName (string username) + +Get user by user name + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetUserByNameExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. + + try + { + // Get user by user name + User result = apiInstance.GetUserByName(username); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetUserByNameWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Get user by user name + ApiResponse response = apiInstance.GetUserByNameWithHttpInfo(username); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.GetUserByNameWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | +| **598** | Not a real HTTP status code | - | +| **599** | Not a real HTTP status code with a return object | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **LoginUser** +> string LoginUser (string username, string password) + +Logs user into the system + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class LoginUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The user name for login + var password = "password_example"; // string | The password for login in clear text + + try + { + // Logs user into the system + string result = apiInstance.LoginUser(username, password); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the LoginUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Logs user into the system + ApiResponse response = apiInstance.LoginUserWithHttpInfo(username, password); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.LoginUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The user name for login | | +| **password** | **string** | The password for login in clear text | | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **LogoutUser** +> void LogoutUser () + +Logs out current logged in user session + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class LogoutUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + + try + { + // Logs out current logged in user session + apiInstance.LogoutUser(); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the LogoutUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Logs out current logged in user session + apiInstance.LogoutUserWithHttpInfo(); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.LogoutUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdateUser** +> void UpdateUser (User user, string username) + +Updated user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdateUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new User(); // User | Updated user object + var username = "username_example"; // string | name that need to be deleted + + try + { + // Updated user + apiInstance.UpdateUser(user, username); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdateUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Updated user + apiInstance.UpdateUserWithHttpInfo(user, username); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.UpdateUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | Updated user object | | +| **username** | **string** | name that need to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Activity.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Activity.md new file mode 100644 index 000000000000..6f69ec32545d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Activity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Activity +test map of maps + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ActivityOutputElementRepresentation.md new file mode 100644 index 000000000000..33d79a27692f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ActivityOutputElementRepresentation.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ActivityOutputElementRepresentation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Prop1** | **string** | | [optional] +**Prop2** | **Object** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AdditionalPropertiesClass.md new file mode 100644 index 000000000000..2bbe882fcfcc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AdditionalPropertiesClass.md @@ -0,0 +1,17 @@ +# Org.OpenAPITools.Model.AdditionalPropertiesClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] +**EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] +**MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] +**MapProperty** | **Dictionary<string, string>** | | [optional] +**MapWithUndeclaredPropertiesAnytype1** | **Object** | | [optional] +**MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] +**MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] +**MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Animal.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Animal.md new file mode 100644 index 000000000000..1a1760bd8697 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Animal.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Animal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ApiResponse.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ApiResponse.md new file mode 100644 index 000000000000..d89ed1a25dc7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ApiResponse.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.ApiResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int** | | [optional] +**Message** | **string** | | [optional] +**Type** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Apple.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Apple.md new file mode 100644 index 000000000000..9ad1da8cd688 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Apple.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ColorCode** | **string** | | [optional] +**Cultivar** | **string** | | [optional] +**Origin** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AppleReq.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AppleReq.md new file mode 100644 index 000000000000..325521123f12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/AppleReq.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.AppleReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Cultivar** | **string** | | +**Mealy** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 000000000000..a23ba59e609c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ArrayOfArrayOfNumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayArrayNumber** | **List<List<decimal>>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfNumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfNumberOnly.md new file mode 100644 index 000000000000..10b8413439b8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ArrayOfNumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayNumber** | **List<decimal>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayTest.md new file mode 100644 index 000000000000..ed572120cd6d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ArrayTest.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.ArrayTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayArrayOfInteger** | **List<List<long>>** | | [optional] +**ArrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [optional] +**ArrayOfString** | **List<string>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Banana.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Banana.md new file mode 100644 index 000000000000..d32e90cf2985 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Banana.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BananaReq.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BananaReq.md new file mode 100644 index 000000000000..c8372b73c5f7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BananaReq.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.BananaReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | **decimal** | | +**Sweet** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BasquePig.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BasquePig.md new file mode 100644 index 000000000000..db4f7a362268 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/BasquePig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.BasquePig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Capitalization.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Capitalization.md new file mode 100644 index 000000000000..9e225c17232a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Capitalization.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Capitalization + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ATT_NAME** | **string** | Name of the pet | [optional] +**CapitalCamel** | **string** | | [optional] +**CapitalSnake** | **string** | | [optional] +**SCAETHFlowPoints** | **string** | | [optional] +**SmallCamel** | **string** | | [optional] +**SmallSnake** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Cat.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Cat.md new file mode 100644 index 000000000000..310a5e6575ec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Cat.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Cat + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Declawed** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Category.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Category.md new file mode 100644 index 000000000000..6eb0a2e13eaa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Category.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Category + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long** | | [optional] +**Name** | **string** | | [default to "default-name"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCat.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCat.md new file mode 100644 index 000000000000..4085cdef26d3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCat.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ChildCat + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**PetType** | **ChildCatAllOfPetType** | | +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCatAllOfPetType.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCatAllOfPetType.md new file mode 100644 index 000000000000..47a390dc5811 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ChildCatAllOfPetType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.ChildCatAllOfPetType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ClassModel.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ClassModel.md new file mode 100644 index 000000000000..bb35816c9148 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ClassModel.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ClassModel +Model for testing model with \"_class\" property + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Class** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ComplexQuadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ComplexQuadrilateral.md new file mode 100644 index 000000000000..fb00d4ebf089 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ComplexQuadrilateral.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ComplexQuadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DanishPig.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DanishPig.md new file mode 100644 index 000000000000..4d6ec1400a7e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DanishPig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DanishPig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DateOnlyClass.md new file mode 100644 index 000000000000..5dd63b313ccf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DeprecatedObject.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DeprecatedObject.md new file mode 100644 index 000000000000..e90c59555a0d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/DeprecatedObject.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DeprecatedObject + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Dog.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Dog.md new file mode 100644 index 000000000000..70cdc80e83e0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Dog.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Dog + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Breed** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Drawing.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Drawing.md new file mode 100644 index 000000000000..95f49b2ed600 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Drawing.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.Drawing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MainShape** | [**Shape**](Shape.md) | | [optional] +**NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] +**ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArrays.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArrays.md new file mode 100644 index 000000000000..ae3e81632c1b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArrays.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.EnumArrays + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayEnum** | [**List<EnumArraysArrayEnumInner>**](EnumArraysArrayEnumInner.md) | | [optional] +**JustSymbol** | **EnumArraysJustSymbol** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysArrayEnumInner.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysArrayEnumInner.md new file mode 100644 index 000000000000..9c08ed9cfedb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysArrayEnumInner.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumArraysArrayEnumInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysJustSymbol.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysJustSymbol.md new file mode 100644 index 000000000000..4cf0e6434006 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumArraysJustSymbol.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumArraysJustSymbol + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumClass.md new file mode 100644 index 000000000000..d259f0f46968 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumClass.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTest.md new file mode 100644 index 000000000000..898c1ea1fb69 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTest.md @@ -0,0 +1,18 @@ +# Org.OpenAPITools.Model.EnumTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **EnumTestEnumString** | | +**EnumInteger** | **EnumTestEnumInteger** | | [optional] +**EnumIntegerOnly** | **EnumTestEnumIntegerOnly** | | [optional] +**EnumNumber** | **TestEnumParametersEnumQueryDoubleParameter** | | [optional] +**EnumString** | **EnumTestEnumString** | | [optional] +**OuterEnum** | **OuterEnum** | | [optional] +**OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**OuterEnumInteger** | **OuterEnumInteger** | | [optional] +**OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumInteger.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumInteger.md new file mode 100644 index 000000000000..2476caf61c79 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumInteger.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumTestEnumInteger + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumIntegerOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumIntegerOnly.md new file mode 100644 index 000000000000..08f59f08776f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumIntegerOnly.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumTestEnumIntegerOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumString.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumString.md new file mode 100644 index 000000000000..783198941ba8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EnumTestEnumString.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumTestEnumString + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EquilateralTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EquilateralTriangle.md new file mode 100644 index 000000000000..8360b5c16a5b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EquilateralTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.EquilateralTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/File.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/File.md new file mode 100644 index 000000000000..58b9c2fc3698 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/File.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.File +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SourceURI** | **string** | Test capitalization | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FileSchemaTestClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FileSchemaTestClass.md new file mode 100644 index 000000000000..a47efad77d8a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FileSchemaTestClass.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.FileSchemaTestClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**File** | [**File**](File.md) | | [optional] +**Files** | [**List<File>**](File.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FindPetsByStatusStatusParameterInner.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FindPetsByStatusStatusParameterInner.md new file mode 100644 index 000000000000..e4b9110e6a6e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FindPetsByStatusStatusParameterInner.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.FindPetsByStatusStatusParameterInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Foo.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Foo.md new file mode 100644 index 000000000000..b9e7d261736f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Foo.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Foo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [default to "bar"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FooGetDefaultResponse.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FooGetDefaultResponse.md new file mode 100644 index 000000000000..47e50daca3e1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FooGetDefaultResponse.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.FooGetDefaultResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**String** | [**Foo**](Foo.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md new file mode 100644 index 000000000000..0983002c5da1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FormatTest.md @@ -0,0 +1,28 @@ +# Org.OpenAPITools.Model.FormatTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Byte** | **byte[]** | | +**Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] +**DateTime** | **DateTime** | | [optional] +**Decimal** | **decimal** | | [optional] +**Double** | **double** | | [optional] +**Float** | **float** | | [optional] +**Int32** | **int** | | [optional] +**Int64** | **long** | | [optional] +**Integer** | **int** | | [optional] +**PatternWithBackslash** | **string** | None | [optional] +**PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] +**PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] +**String** | **string** | | [optional] +**UnsignedInteger** | **uint** | | [optional] +**UnsignedLong** | **ulong** | | [optional] +**Uuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Fruit.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Fruit.md new file mode 100644 index 000000000000..b3bee18f7ba0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Fruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FruitReq.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FruitReq.md new file mode 100644 index 000000000000..38ab0c1a6caa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/FruitReq.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.FruitReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GmFruit.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GmFruit.md new file mode 100644 index 000000000000..584c4fd323d8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GmFruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.GmFruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GrandparentAnimal.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GrandparentAnimal.md new file mode 100644 index 000000000000..eca96162b6f8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/GrandparentAnimal.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.GrandparentAnimal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**PetType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HasOnlyReadOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HasOnlyReadOnly.md new file mode 100644 index 000000000000..060a614a6981 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.HasOnlyReadOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [readonly] +**Foo** | **string** | | [optional] [readonly] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HealthCheckResult.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HealthCheckResult.md new file mode 100644 index 000000000000..682cfc50e3a4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/HealthCheckResult.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.HealthCheckResult +Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**NullableMessage** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/IsoscelesTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/IsoscelesTriangle.md new file mode 100644 index 000000000000..07c62ac93382 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/IsoscelesTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.IsoscelesTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/List.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/List.md new file mode 100644 index 000000000000..0b54858ac247 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/List.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.List + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Var123List** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/LiteralStringClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/LiteralStringClass.md new file mode 100644 index 000000000000..782021909655 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/LiteralStringClass.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.LiteralStringClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EscapedLiteralString** | **string** | | [optional] [default to "C:\\Users\\username"] +**UnescapedLiteralString** | **string** | | [optional] [default to "C:\Users\username"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Mammal.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Mammal.md new file mode 100644 index 000000000000..ac14f00c0ff0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Mammal.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Mammal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTest.md new file mode 100644 index 000000000000..b2dea1b6cb44 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTest.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.MapTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DirectMap** | **Dictionary<string, bool>** | | [optional] +**IndirectMap** | **Dictionary<string, bool>** | | [optional] +**MapMapOfString** | **Dictionary<string, Dictionary<string, string>>** | | [optional] +**MapOfEnumString** | [**Dictionary<string, MapTestMapOfEnumStringValue>**](MapTestMapOfEnumStringValue.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTestMapOfEnumStringValue.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTestMapOfEnumStringValue.md new file mode 100644 index 000000000000..f587f829988f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MapTestMapOfEnumStringValue.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MapTestMapOfEnumStringValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixLog.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixLog.md new file mode 100644 index 000000000000..5184c03bea97 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixLog.md @@ -0,0 +1,41 @@ +# Org.OpenAPITools.Model.MixLog + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Description** | **string** | | +**FormulaVersionDate** | **DateTime** | | +**Id** | **Guid** | | +**MixDate** | **DateTime** | | +**TotalOverPoors** | **int** | | +**TotalRecalculations** | **int** | | +**TotalSkips** | **int** | | +**TotalUnderPours** | **int** | | +**BatchNumber** | **string** | | [optional] +**BrandCode** | **string** | BrandCode is only required for non-color mixes | [optional] +**BrandId** | **string** | BrandId is only required for color mixes | [optional] +**BrandName** | **string** | BrandName is only required for color mixes | [optional] +**CategoryCode** | **string** | CategoryCode is not used anymore | [optional] +**Color** | **string** | Color is only required for color mixes | [optional] +**ColorDescription** | **string** | | [optional] +**Comment** | **string** | | [optional] +**CommercialProductCode** | **string** | | [optional] +**Country** | **string** | | [optional] +**CreatedBy** | **string** | | [optional] +**CreatedByFirstName** | **string** | | [optional] +**CreatedByLastName** | **string** | | [optional] +**DeltaECalculationRepaired** | **string** | | [optional] +**DeltaECalculationSprayout** | **string** | | [optional] +**OwnColorVariantNumber** | **int** | | [optional] +**PrimerProductId** | **string** | | [optional] +**ProductId** | **string** | ProductId is only required for color mixes | [optional] +**ProductLineCode** | **string** | ProductLineCode is only required for color mixes | [optional] +**ProductName** | **string** | ProductName is only required for color mixes | [optional] +**SelectedVersionIndex** | **int** | | [optional] +**ShopId** | **Guid** | | [optional] +**SomeCode** | **string** | SomeCode is only required for color mixes | [optional] +**TotalPrice** | **float** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 000000000000..1bc0740add9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.MixedPropertiesAndAdditionalPropertiesClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateTime** | **DateTime** | | [optional] +**Map** | [**Dictionary<string, Animal>**](Animal.md) | | [optional] +**Uuid** | **Guid** | | [optional] +**UuidWithPattern** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Model200Response.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Model200Response.md new file mode 100644 index 000000000000..2752a0d87c82 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Model200Response.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Model200Response +Model for testing model name starting with number + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Class** | **string** | | [optional] +**Name** | **int** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ModelClient.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ModelClient.md new file mode 100644 index 000000000000..c658e84ef57e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ModelClient.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ModelClient + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarClient** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Name.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Name.md new file mode 100644 index 000000000000..ffe61a31d61b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Name.md @@ -0,0 +1,14 @@ +# Org.OpenAPITools.Model.Name +Model for testing model name same as property name + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarName** | **int** | | +**Property** | **string** | | [optional] +**SnakeCase** | **int** | | [optional] [readonly] +**Var123Number** | **int** | | [optional] [readonly] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NotificationtestGetElementsV1ResponseMPayload.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NotificationtestGetElementsV1ResponseMPayload.md new file mode 100644 index 000000000000..25f223a8360a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NotificationtestGetElementsV1ResponseMPayload.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AObjVariableobject** | **List<Dictionary<string, Object>>** | | +**PkiNotificationtestID** | **int** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableClass.md new file mode 100644 index 000000000000..5d9965f55c0a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableClass.md @@ -0,0 +1,21 @@ +# Org.OpenAPITools.Model.NullableClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] +**ArrayNullableProp** | **List<Object>** | | [optional] +**BooleanProp** | **bool** | | [optional] +**DateProp** | **DateTime** | | [optional] +**DatetimeProp** | **DateTime** | | [optional] +**IntegerProp** | **int** | | [optional] +**NumberProp** | **decimal** | | [optional] +**ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] +**ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] +**StringProp** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableGuidClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableGuidClass.md new file mode 100644 index 000000000000..8d939afe9984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableGuidClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.NullableGuidClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Uuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableShape.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableShape.md new file mode 100644 index 000000000000..2720167ccaaa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NullableShape.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.NullableShape +The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NumberOnly.md new file mode 100644 index 000000000000..1b83cce764d3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/NumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.NumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**JustNumber** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ObjectWithDeprecatedFields.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ObjectWithDeprecatedFields.md new file mode 100644 index 000000000000..9f44c24d19ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ObjectWithDeprecatedFields.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.ObjectWithDeprecatedFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bars** | **List<string>** | | [optional] +**DeprecatedRef** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] +**Id** | **decimal** | | [optional] +**Uuid** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OneOfString.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OneOfString.md new file mode 100644 index 000000000000..54caf618776c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OneOfString.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OneOfString + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Order.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Order.md new file mode 100644 index 000000000000..f3fcb0f21f87 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Order.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] +**Id** | **long** | | [optional] +**PetId** | **long** | | [optional] +**Quantity** | **int** | | [optional] +**ShipDate** | **DateTime** | | [optional] +**Status** | **OrderStatus** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OrderStatus.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OrderStatus.md new file mode 100644 index 000000000000..5a80d8efa8ce --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OrderStatus.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.OrderStatus +Order Status + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterComposite.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterComposite.md new file mode 100644 index 000000000000..8985c59d094f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterComposite.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.OuterComposite + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MyBoolean** | **bool** | | [optional] +**MyNumber** | **decimal** | | [optional] +**MyString** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnum.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnum.md new file mode 100644 index 000000000000..36844bc4b175 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnum.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumDefaultValue.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumDefaultValue.md new file mode 100644 index 000000000000..351383f0aeae --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumDefaultValue.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumDefaultValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumInteger.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumInteger.md new file mode 100644 index 000000000000..1013b5b19565 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumInteger.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumInteger + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumIntegerDefaultValue.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumIntegerDefaultValue.md new file mode 100644 index 000000000000..55e314e3102d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumIntegerDefaultValue.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumIntegerDefaultValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumTest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumTest.md new file mode 100644 index 000000000000..b99d27c2c2e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/OuterEnumTest.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ParentPet.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ParentPet.md new file mode 100644 index 000000000000..bdf570056372 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ParentPet.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ParentPet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**PetType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pet.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pet.md new file mode 100644 index 000000000000..2de6e7ef512f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pet.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Pet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | +**PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] +**Status** | **PetStatus** | | [optional] +**Tags** | [**List<Tag>**](Tag.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PetStatus.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PetStatus.md new file mode 100644 index 000000000000..c710ca8cbcef --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PetStatus.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.PetStatus +pet status in the store + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pig.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pig.md new file mode 100644 index 000000000000..fd7bb9359ac4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Pig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Pig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PolymorphicProperty.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PolymorphicProperty.md new file mode 100644 index 000000000000..4507ec41cd51 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/PolymorphicProperty.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.PolymorphicProperty + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Quadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Quadrilateral.md new file mode 100644 index 000000000000..fbbf4f81cec6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Quadrilateral.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Quadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/QuadrilateralInterface.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/QuadrilateralInterface.md new file mode 100644 index 000000000000..756ba09c6ddf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/QuadrilateralInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.QuadrilateralInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ReadOnlyFirst.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ReadOnlyFirst.md new file mode 100644 index 000000000000..afaf2ee4fb6c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ReadOnlyFirst.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ReadOnlyFirst + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [readonly] +**Baz** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClass.md new file mode 100644 index 000000000000..11265eef841e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **RequiredClassRequiredNotnullableEnumInteger** | | +**RequiredNotnullableEnumIntegerOnly** | **RequiredClassRequiredNotnullableEnumIntegerOnly** | | +**RequiredNotnullableEnumString** | **RequiredClassRequiredNotnullableEnumString** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **RequiredClassRequiredNotnullableEnumInteger** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **RequiredClassRequiredNotnullableEnumIntegerOnly** | | [optional] +**NotrequiredNotnullableEnumString** | **RequiredClassRequiredNotnullableEnumString** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **RequiredClassRequiredNullableEnumInteger** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **RequiredClassRequiredNullableEnumIntegerOnly** | | [optional] +**NotrequiredNullableEnumString** | **RequiredClassRequiredNullableEnumString** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **RequiredClassRequiredNullableEnumInteger** | | +**RequiredNullableEnumIntegerOnly** | **RequiredClassRequiredNullableEnumIntegerOnly** | | +**RequiredNullableEnumString** | **RequiredClassRequiredNullableEnumString** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumInteger.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumInteger.md new file mode 100644 index 000000000000..e229576c45b9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumInteger.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNotnullableEnumInteger + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumIntegerOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumIntegerOnly.md new file mode 100644 index 000000000000..da648bc919dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumIntegerOnly.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNotnullableEnumIntegerOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumString.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumString.md new file mode 100644 index 000000000000..d0e080d727c8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNotnullableEnumString.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNotnullableEnumString + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumInteger.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumInteger.md new file mode 100644 index 000000000000..7f04aa4d2457 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumInteger.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNullableEnumInteger + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md new file mode 100644 index 000000000000..2d0eb8b05c51 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNullableEnumIntegerOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumString.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumString.md new file mode 100644 index 000000000000..cb0fbdac213d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RequiredClassRequiredNullableEnumString.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.RequiredClassRequiredNullableEnumString + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Return.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Return.md new file mode 100644 index 000000000000..ad96a170bbbb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Return.md @@ -0,0 +1,14 @@ +# Org.OpenAPITools.Model.Return +Model for testing reserved words + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Lock** | **string** | | +**Abstract** | **string** | | +**VarReturn** | **int** | | [optional] +**Unsafe** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHash.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHash.md new file mode 100644 index 000000000000..d92c01de9ef7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHash.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.RolesReportsHash +Role report Hash + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Role** | [**RolesReportsHashRole**](RolesReportsHashRole.md) | | [optional] +**RoleUuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHashRole.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHashRole.md new file mode 100644 index 000000000000..760f77b30e78 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/RolesReportsHashRole.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.RolesReportsHashRole + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ScaleneTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ScaleneTriangle.md new file mode 100644 index 000000000000..d3f15354bccc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ScaleneTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ScaleneTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Shape.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Shape.md new file mode 100644 index 000000000000..ae75c5925401 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Shape.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Shape + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeInterface.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeInterface.md new file mode 100644 index 000000000000..882d31868305 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ShapeInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeOrNull.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeOrNull.md new file mode 100644 index 000000000000..7fcd31a3a5e1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ShapeOrNull.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ShapeOrNull +The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SimpleQuadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SimpleQuadrilateral.md new file mode 100644 index 000000000000..a9c7f93b67ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SimpleQuadrilateral.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.SimpleQuadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SpecialModelName.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SpecialModelName.md new file mode 100644 index 000000000000..890bcd923dee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/SpecialModelName.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.SpecialModelName + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarSpecialModelName** | **string** | | [optional] +**SpecialPropertyName** | **long** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Tag.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Tag.md new file mode 100644 index 000000000000..2b2d9674d619 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Tag.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Tag + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long** | | [optional] +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordList.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordList.md new file mode 100644 index 000000000000..5c5eb22d9a8a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordList.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestCollectionEndingWithWordList + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Value** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordListObject.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordListObject.md new file mode 100644 index 000000000000..cfa933cc576e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestCollectionEndingWithWordListObject.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestCollectionEndingWithWordListObject + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TestCollectionEndingWithWordList** | [**List<TestCollectionEndingWithWordList>**](TestCollectionEndingWithWordList.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumHeaderStringParameter.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumHeaderStringParameter.md new file mode 100644 index 000000000000..b5768f76fa5c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumHeaderStringParameter.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.TestEnumParametersEnumHeaderStringParameter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryDoubleParameter.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryDoubleParameter.md new file mode 100644 index 000000000000..72510955c1a9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryDoubleParameter.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.TestEnumParametersEnumQueryDoubleParameter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryIntegerParameter.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryIntegerParameter.md new file mode 100644 index 000000000000..b2c9b9c5a9d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersEnumQueryIntegerParameter.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.TestEnumParametersEnumQueryIntegerParameter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormString.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormString.md new file mode 100644 index 000000000000..b734496b5fb8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormString.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestEnumParametersRequestEnumFormString +Form parameter enum test (string) + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md new file mode 100644 index 000000000000..ca4e762853a0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.TestEnumParametersRequestEnumFormStringArrayInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md new file mode 100644 index 000000000000..b6f9fc948474 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestInlineFreeformAdditionalPropertiesRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SomeProperty** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Triangle.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Triangle.md new file mode 100644 index 000000000000..e15109911958 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Triangle.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Triangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TriangleInterface.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TriangleInterface.md new file mode 100644 index 000000000000..4127c08b14f3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TriangleInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TriangleInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/User.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/User.md new file mode 100644 index 000000000000..b5700f1c75d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/User.md @@ -0,0 +1,21 @@ +# Org.OpenAPITools.Model.User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] +**Email** | **string** | | [optional] +**FirstName** | **string** | | [optional] +**Id** | **long** | | [optional] +**LastName** | **string** | | [optional] +**ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] +**Password** | **string** | | [optional] +**Phone** | **string** | | [optional] +**UserStatus** | **int** | User Status | [optional] +**Username** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Whale.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Whale.md new file mode 100644 index 000000000000..1c633fdce61b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Whale.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Whale + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**HasBaleen** | **bool** | | [optional] +**HasTeeth** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Zebra.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Zebra.md new file mode 100644 index 000000000000..5b0d67809694 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Zebra.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Zebra + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Type** | **ZebraType** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZebraType.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZebraType.md new file mode 100644 index 000000000000..d31970174902 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZebraType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.ZebraType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnum.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnum.md new file mode 100644 index 000000000000..cb71966c4c81 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnum.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.ZeroBasedEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClass.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClass.md new file mode 100644 index 000000000000..afb2e8630644 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ZeroBasedEnumClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ZeroBasedEnum** | **ZeroBasedEnumClassZeroBasedEnum** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClassZeroBasedEnum.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClassZeroBasedEnum.md new file mode 100644 index 000000000000..bf5145894ad6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/ZeroBasedEnumClassZeroBasedEnum.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.ZeroBasedEnumClassZeroBasedEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs new file mode 100644 index 000000000000..cf82a3e39bd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing AnotherFakeApi + /// + public sealed class AnotherFakeApiTests : ApiTestsBase + { + private readonly IAnotherFakeApi _instance; + + public AnotherFakeApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test Call123TestSpecialTags + /// + [Fact (Skip = "not implemented")] + public async Task Call123TestSpecialTagsAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.Call123TestSpecialTagsAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..c178aac4eabe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,81 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + string apiKeyTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + ApiKeyToken apiKeyToken1 = new ApiKeyToken(apiKeyTokenValue1, ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + string apiKeyTokenValue2 = context.Configuration[""] ?? throw new Exception("Token not found."); + ApiKeyToken apiKeyToken2 = new ApiKeyToken(apiKeyTokenValue2, ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + string bearerTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + BearerToken bearerToken1 = new BearerToken(bearerTokenValue1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + string basicTokenUsername1 = context.Configuration[""] ?? throw new Exception("Username not found."); + string basicTokenPassword1 = context.Configuration[""] ?? throw new Exception("Password not found."); + BasicToken basicToken1 = new BasicToken(basicTokenUsername1, basicTokenPassword1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + string oauthTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + OAuthToken oauthToken1 = new OAuthToken(oauthTokenValue1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..88cf05ba9ed8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test FooGet + /// + [Fact (Skip = "not implemented")] + public async Task FooGetAsyncTest() + { + var response = await _instance.FooGetAsync(); + var model = response.Default(); + Assert.IsType(model); + } + + /// + /// Test GetCountry + /// + [Fact (Skip = "not implemented")] + public async Task GetCountryAsyncTest() + { + string country = default; + await _instance.GetCountryAsync(country); + } + + /// + /// Test Hello + /// + [Fact (Skip = "not implemented")] + public async Task HelloAsyncTest() + { + var response = await _instance.HelloAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test RolesReportGet + /// + [Fact (Skip = "not implemented")] + public async Task RolesReportGetAsyncTest() + { + var response = await _instance.RolesReportGetAsync(); + var model = response.Ok(); + Assert.IsType>>(model); + } + + /// + /// Test Test + /// + [Fact (Skip = "not implemented")] + public async Task TestAsyncTest() + { + var response = await _instance.TestAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..bbccd77b29c1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,243 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken); + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var anotherFakeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var anotherFakeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var anotherFakeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var anotherFakeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs new file mode 100644 index 000000000000..f57f666628d8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -0,0 +1,281 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing FakeApi + /// + public sealed class FakeApiTests : ApiTestsBase + { + private readonly IFakeApi _instance; + + public FakeApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test FakeHealthGet + /// + [Fact (Skip = "not implemented")] + public async Task FakeHealthGetAsyncTest() + { + var response = await _instance.FakeHealthGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterBooleanSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterBooleanSerializeAsyncTest() + { + Client.Option body = default; + var response = await _instance.FakeOuterBooleanSerializeAsync(body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterCompositeSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterCompositeSerializeAsyncTest() + { + Client.Option outerComposite = default; + var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterNumberSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterNumberSerializeAsyncTest() + { + Client.Option body = default; + var response = await _instance.FakeOuterNumberSerializeAsync(body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterStringSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterStringSerializeAsyncTest() + { + Guid requiredStringUuid = default; + Client.Option body = default; + var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetArrayOfEnums + /// + [Fact (Skip = "not implemented")] + public async Task GetArrayOfEnumsAsyncTest() + { + var response = await _instance.GetArrayOfEnumsAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test TestAdditionalPropertiesReference + /// + [Fact (Skip = "not implemented")] + public async Task TestAdditionalPropertiesReferenceAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestAdditionalPropertiesReferenceAsync(requestBody); + } + + /// + /// Test TestBodyWithFileSchema + /// + [Fact (Skip = "not implemented")] + public async Task TestBodyWithFileSchemaAsyncTest() + { + FileSchemaTestClass fileSchemaTestClass = default; + await _instance.TestBodyWithFileSchemaAsync(fileSchemaTestClass); + } + + /// + /// Test TestBodyWithQueryParams + /// + [Fact (Skip = "not implemented")] + public async Task TestBodyWithQueryParamsAsyncTest() + { + User user = default; + string query = default; + await _instance.TestBodyWithQueryParamsAsync(user, query); + } + + /// + /// Test TestClientModel + /// + [Fact (Skip = "not implemented")] + public async Task TestClientModelAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.TestClientModelAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test TestEndpointParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestEndpointParametersAsyncTest() + { + byte[] varByte = default; + decimal number = default; + double varDouble = default; + string patternWithoutDelimiter = default; + Client.Option date = default; + Client.Option binary = default; + Client.Option varFloat = default; + Client.Option integer = default; + Client.Option int32 = default; + Client.Option int64 = default; + Client.Option varString = default; + Client.Option password = default; + Client.Option callback = default; + Client.Option dateTime = default; + await _instance.TestEndpointParametersAsync(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + } + + /// + /// Test TestEnumParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestEnumParametersAsyncTest() + { + Client.Option> enumHeaderStringArray = default; + Client.Option> enumQueryStringArray = default; + Client.Option> enumFormStringArray = default; + Client.Option enumHeaderString = default; + Client.Option enumQueryString = default; + Client.Option enumQueryDouble = default; + Client.Option enumQueryInteger = default; + Client.Option enumFormString = default; + await _instance.TestEnumParametersAsync(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + } + + /// + /// Test TestGroupParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestGroupParametersAsyncTest() + { + bool requiredBooleanGroup = default; + int requiredStringGroup = default; + long requiredInt64Group = default; + Client.Option booleanGroup = default; + Client.Option stringGroup = default; + Client.Option int64Group = default; + await _instance.TestGroupParametersAsync(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + } + + /// + /// Test TestInlineAdditionalProperties + /// + [Fact (Skip = "not implemented")] + public async Task TestInlineAdditionalPropertiesAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestInlineAdditionalPropertiesAsync(requestBody); + } + + /// + /// Test TestInlineFreeformAdditionalProperties + /// + [Fact (Skip = "not implemented")] + public async Task TestInlineFreeformAdditionalPropertiesAsyncTest() + { + TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest = default; + await _instance.TestInlineFreeformAdditionalPropertiesAsync(testInlineFreeformAdditionalPropertiesRequest); + } + + /// + /// Test TestJsonFormData + /// + [Fact (Skip = "not implemented")] + public async Task TestJsonFormDataAsyncTest() + { + string param = default; + string param2 = default; + await _instance.TestJsonFormDataAsync(param, param2); + } + + /// + /// Test TestQueryParameterCollectionFormat + /// + [Fact (Skip = "not implemented")] + public async Task TestQueryParameterCollectionFormatAsyncTest() + { + List pipe = default; + List ioutil = default; + List http = default; + List url = default; + List context = default; + string requiredNotNullable = default; + string requiredNullable = default; + Client.Option notRequiredNotNullable = default; + Client.Option notRequiredNullable = default; + await _instance.TestQueryParameterCollectionFormatAsync(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + } + + /// + /// Test TestStringMapReference + /// + [Fact (Skip = "not implemented")] + public async Task TestStringMapReferenceAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestStringMapReferenceAsync(requestBody); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs new file mode 100644 index 000000000000..5964bf6e51d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing FakeClassnameTags123Api + /// + public sealed class FakeClassnameTags123ApiTests : ApiTestsBase + { + private readonly IFakeClassnameTags123Api _instance; + + public FakeClassnameTags123ApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test TestClassname + /// + [Fact (Skip = "not implemented")] + public async Task TestClassnameAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.TestClassnameAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs new file mode 100644 index 000000000000..01ef5de875ec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -0,0 +1,160 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing PetApi + /// + public sealed class PetApiTests : ApiTestsBase + { + private readonly IPetApi _instance; + + public PetApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test AddPet + /// + [Fact (Skip = "not implemented")] + public async Task AddPetAsyncTest() + { + Pet pet = default; + await _instance.AddPetAsync(pet); + } + + /// + /// Test DeletePet + /// + [Fact (Skip = "not implemented")] + public async Task DeletePetAsyncTest() + { + long petId = default; + Client.Option apiKey = default; + await _instance.DeletePetAsync(petId, apiKey); + } + + /// + /// Test FindPetsByStatus + /// + [Fact (Skip = "not implemented")] + public async Task FindPetsByStatusAsyncTest() + { + List status = default; + var response = await _instance.FindPetsByStatusAsync(status); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test FindPetsByTags + /// + [Fact (Skip = "not implemented")] + public async Task FindPetsByTagsAsyncTest() + { + List tags = default; + var response = await _instance.FindPetsByTagsAsync(tags); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test GetPetById + /// + [Fact (Skip = "not implemented")] + public async Task GetPetByIdAsyncTest() + { + long petId = default; + var response = await _instance.GetPetByIdAsync(petId); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test UpdatePet + /// + [Fact (Skip = "not implemented")] + public async Task UpdatePetAsyncTest() + { + Pet pet = default; + await _instance.UpdatePetAsync(pet); + } + + /// + /// Test UpdatePetWithForm + /// + [Fact (Skip = "not implemented")] + public async Task UpdatePetWithFormAsyncTest() + { + long petId = default; + Client.Option name = default; + Client.Option status = default; + await _instance.UpdatePetWithFormAsync(petId, name, status); + } + + /// + /// Test UploadFile + /// + [Fact (Skip = "not implemented")] + public async Task UploadFileAsyncTest() + { + long petId = default; + Client.Option file = default; + Client.Option additionalMetadata = default; + var response = await _instance.UploadFileAsync(petId, file, additionalMetadata); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test UploadFileWithRequiredFile + /// + [Fact (Skip = "not implemented")] + public async Task UploadFileWithRequiredFileAsyncTest() + { + System.IO.Stream requiredFile = default; + long petId = default; + Client.Option additionalMetadata = default; + var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs new file mode 100644 index 000000000000..1b75e3417005 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs @@ -0,0 +1,98 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing StoreApi + /// + public sealed class StoreApiTests : ApiTestsBase + { + private readonly IStoreApi _instance; + + public StoreApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test DeleteOrder + /// + [Fact (Skip = "not implemented")] + public async Task DeleteOrderAsyncTest() + { + string orderId = default; + await _instance.DeleteOrderAsync(orderId); + } + + /// + /// Test GetInventory + /// + [Fact (Skip = "not implemented")] + public async Task GetInventoryAsyncTest() + { + var response = await _instance.GetInventoryAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test GetOrderById + /// + [Fact (Skip = "not implemented")] + public async Task GetOrderByIdAsyncTest() + { + long orderId = default; + var response = await _instance.GetOrderByIdAsync(orderId); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test PlaceOrder + /// + [Fact (Skip = "not implemented")] + public async Task PlaceOrderAsyncTest() + { + Order order = default; + var response = await _instance.PlaceOrderAsync(order); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/UserApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/UserApiTests.cs new file mode 100644 index 000000000000..38ee1125438a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/UserApiTests.cs @@ -0,0 +1,138 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing UserApi + /// + public sealed class UserApiTests : ApiTestsBase + { + private readonly IUserApi _instance; + + public UserApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test CreateUser + /// + [Fact (Skip = "not implemented")] + public async Task CreateUserAsyncTest() + { + User user = default; + await _instance.CreateUserAsync(user); + } + + /// + /// Test CreateUsersWithArrayInput + /// + [Fact (Skip = "not implemented")] + public async Task CreateUsersWithArrayInputAsyncTest() + { + List user = default; + await _instance.CreateUsersWithArrayInputAsync(user); + } + + /// + /// Test CreateUsersWithListInput + /// + [Fact (Skip = "not implemented")] + public async Task CreateUsersWithListInputAsyncTest() + { + List user = default; + await _instance.CreateUsersWithListInputAsync(user); + } + + /// + /// Test DeleteUser + /// + [Fact (Skip = "not implemented")] + public async Task DeleteUserAsyncTest() + { + string username = default; + await _instance.DeleteUserAsync(username); + } + + /// + /// Test GetUserByName + /// + [Fact (Skip = "not implemented")] + public async Task GetUserByNameAsyncTest() + { + string username = default; + var response = await _instance.GetUserByNameAsync(username); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test LoginUser + /// + [Fact (Skip = "not implemented")] + public async Task LoginUserAsyncTest() + { + string username = default; + string password = default; + var response = await _instance.LoginUserAsync(username, password); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test LogoutUser + /// + [Fact (Skip = "not implemented")] + public async Task LogoutUserAsyncTest() + { + await _instance.LogoutUserAsync(); + } + + /// + /// Test UpdateUser + /// + [Fact (Skip = "not implemented")] + public async Task UpdateUserAsyncTest() + { + User user = default; + string username = default; + await _instance.UpdateUserAsync(user, username); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs new file mode 100644 index 000000000000..adbf639fd720 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ActivityOutputElementRepresentation + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ActivityOutputElementRepresentationTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation + //private ActivityOutputElementRepresentation instance; + + public ActivityOutputElementRepresentationTests() + { + // TODO uncomment below to create an instance of ActivityOutputElementRepresentation + //instance = new ActivityOutputElementRepresentation(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ActivityOutputElementRepresentation + /// + [Fact] + public void ActivityOutputElementRepresentationInstanceTest() + { + // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation + //Assert.IsType(instance); + } + + /// + /// Test the property 'Prop1' + /// + [Fact] + public void Prop1Test() + { + // TODO unit test for the property 'Prop1' + } + + /// + /// Test the property 'Prop2' + /// + [Fact] + public void Prop2Test() + { + // TODO unit test for the property 'Prop2' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityTests.cs new file mode 100644 index 000000000000..6cc2927eaaf3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ActivityTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Activity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Activity + //private Activity instance; + + public ActivityTests() + { + // TODO uncomment below to create an instance of Activity + //instance = new Activity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Activity + /// + [Fact] + public void ActivityInstanceTest() + { + // TODO uncomment below to test "IsType" Activity + //Assert.IsType(instance); + } + + /// + /// Test the property 'ActivityOutputs' + /// + [Fact] + public void ActivityOutputsTest() + { + // TODO unit test for the property 'ActivityOutputs' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs new file mode 100644 index 000000000000..e157b477193e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs @@ -0,0 +1,128 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing AdditionalPropertiesClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AdditionalPropertiesClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for AdditionalPropertiesClass + //private AdditionalPropertiesClass instance; + + public AdditionalPropertiesClassTests() + { + // TODO uncomment below to create an instance of AdditionalPropertiesClass + //instance = new AdditionalPropertiesClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of AdditionalPropertiesClass + /// + [Fact] + public void AdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsType" AdditionalPropertiesClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'Anytype1' + /// + [Fact] + public void Anytype1Test() + { + // TODO unit test for the property 'Anytype1' + } + + /// + /// Test the property 'EmptyMap' + /// + [Fact] + public void EmptyMapTest() + { + // TODO unit test for the property 'EmptyMap' + } + + /// + /// Test the property 'MapOfMapProperty' + /// + [Fact] + public void MapOfMapPropertyTest() + { + // TODO unit test for the property 'MapOfMapProperty' + } + + /// + /// Test the property 'MapProperty' + /// + [Fact] + public void MapPropertyTest() + { + // TODO unit test for the property 'MapProperty' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype1' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype1Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype1' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype2' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype2Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype2' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype3' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype3Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype3' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesString' + /// + [Fact] + public void MapWithUndeclaredPropertiesStringTest() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AnimalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AnimalTests.cs new file mode 100644 index 000000000000..1db9725afb85 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AnimalTests.cs @@ -0,0 +1,94 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Animal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AnimalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Animal + //private Animal instance; + + public AnimalTests() + { + // TODO uncomment below to create an instance of Animal + //instance = new Animal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Animal + /// + [Fact] + public void AnimalInstanceTest() + { + // TODO uncomment below to test "IsType" Animal + //Assert.IsType(instance); + } + + /// + /// Test deserialize a Cat from type Animal + /// + [Fact] + public void CatDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Cat from type Animal + //Assert.IsType(JsonConvert.DeserializeObject(new Cat().ToJson())); + } + + /// + /// Test deserialize a Dog from type Animal + /// + [Fact] + public void DogDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Dog from type Animal + //Assert.IsType(JsonConvert.DeserializeObject(new Dog().ToJson())); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs new file mode 100644 index 000000000000..c296a82116a7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ApiResponse + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ApiResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ApiResponse + //private ApiResponse instance; + + public ApiResponseTests() + { + // TODO uncomment below to create an instance of ApiResponse + //instance = new ApiResponse(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ApiResponse + /// + [Fact] + public void ApiResponseInstanceTest() + { + // TODO uncomment below to test "IsType" ApiResponse + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Message' + /// + [Fact] + public void MessageTest() + { + // TODO unit test for the property 'Message' + } + + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs new file mode 100644 index 000000000000..d698ee445048 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing AppleReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for AppleReq + //private AppleReq instance; + + public AppleReqTests() + { + // TODO uncomment below to create an instance of AppleReq + //instance = new AppleReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of AppleReq + /// + [Fact] + public void AppleReqInstanceTest() + { + // TODO uncomment below to test "IsType" AppleReq + //Assert.IsType(instance); + } + + /// + /// Test the property 'Cultivar' + /// + [Fact] + public void CultivarTest() + { + // TODO unit test for the property 'Cultivar' + } + + /// + /// Test the property 'Mealy' + /// + [Fact] + public void MealyTest() + { + // TODO unit test for the property 'Mealy' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleTests.cs new file mode 100644 index 000000000000..c7c8ccd47c11 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/AppleTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Apple + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Apple + //private Apple instance; + + public AppleTests() + { + // TODO uncomment below to create an instance of Apple + //instance = new Apple(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Apple + /// + [Fact] + public void AppleInstanceTest() + { + // TODO uncomment below to test "IsType" Apple + //Assert.IsType(instance); + } + + /// + /// Test the property 'ColorCode' + /// + [Fact] + public void ColorCodeTest() + { + // TODO unit test for the property 'ColorCode' + } + + /// + /// Test the property 'Cultivar' + /// + [Fact] + public void CultivarTest() + { + // TODO unit test for the property 'Cultivar' + } + + /// + /// Test the property 'Origin' + /// + [Fact] + public void OriginTest() + { + // TODO unit test for the property 'Origin' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs new file mode 100644 index 000000000000..29fe9cfb1d47 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayOfArrayOfNumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayOfArrayOfNumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayOfArrayOfNumberOnly + //private ArrayOfArrayOfNumberOnly instance; + + public ArrayOfArrayOfNumberOnlyTests() + { + // TODO uncomment below to create an instance of ArrayOfArrayOfNumberOnly + //instance = new ArrayOfArrayOfNumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayOfArrayOfNumberOnly + /// + [Fact] + public void ArrayOfArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayOfArrayOfNumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayArrayNumber' + /// + [Fact] + public void ArrayArrayNumberTest() + { + // TODO unit test for the property 'ArrayArrayNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs new file mode 100644 index 000000000000..2b0956c0b984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayOfNumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayOfNumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayOfNumberOnly + //private ArrayOfNumberOnly instance; + + public ArrayOfNumberOnlyTests() + { + // TODO uncomment below to create an instance of ArrayOfNumberOnly + //instance = new ArrayOfNumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayOfNumberOnly + /// + [Fact] + public void ArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayOfNumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayNumber' + /// + [Fact] + public void ArrayNumberTest() + { + // TODO unit test for the property 'ArrayNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs new file mode 100644 index 000000000000..3b01d0b7abbc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayTest + //private ArrayTest instance; + + public ArrayTestTests() + { + // TODO uncomment below to create an instance of ArrayTest + //instance = new ArrayTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayTest + /// + [Fact] + public void ArrayTestInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayArrayOfInteger' + /// + [Fact] + public void ArrayArrayOfIntegerTest() + { + // TODO unit test for the property 'ArrayArrayOfInteger' + } + + /// + /// Test the property 'ArrayArrayOfModel' + /// + [Fact] + public void ArrayArrayOfModelTest() + { + // TODO unit test for the property 'ArrayArrayOfModel' + } + + /// + /// Test the property 'ArrayOfString' + /// + [Fact] + public void ArrayOfStringTest() + { + // TODO unit test for the property 'ArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs new file mode 100644 index 000000000000..1e54c1f3e41d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing BananaReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for BananaReq + //private BananaReq instance; + + public BananaReqTests() + { + // TODO uncomment below to create an instance of BananaReq + //instance = new BananaReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of BananaReq + /// + [Fact] + public void BananaReqInstanceTest() + { + // TODO uncomment below to test "IsType" BananaReq + //Assert.IsType(instance); + } + + /// + /// Test the property 'LengthCm' + /// + [Fact] + public void LengthCmTest() + { + // TODO unit test for the property 'LengthCm' + } + + /// + /// Test the property 'Sweet' + /// + [Fact] + public void SweetTest() + { + // TODO unit test for the property 'Sweet' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaTests.cs new file mode 100644 index 000000000000..5a88e9dabbdf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BananaTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Banana + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Banana + //private Banana instance; + + public BananaTests() + { + // TODO uncomment below to create an instance of Banana + //instance = new Banana(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Banana + /// + [Fact] + public void BananaInstanceTest() + { + // TODO uncomment below to test "IsType" Banana + //Assert.IsType(instance); + } + + /// + /// Test the property 'LengthCm' + /// + [Fact] + public void LengthCmTest() + { + // TODO unit test for the property 'LengthCm' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs new file mode 100644 index 000000000000..4ffd6c2c0c87 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing BasquePig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BasquePigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for BasquePig + //private BasquePig instance; + + public BasquePigTests() + { + // TODO uncomment below to create an instance of BasquePig + //instance = new BasquePig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of BasquePig + /// + [Fact] + public void BasquePigInstanceTest() + { + // TODO uncomment below to test "IsType" BasquePig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs new file mode 100644 index 000000000000..d0391fb47f8f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Capitalization + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CapitalizationTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Capitalization + //private Capitalization instance; + + public CapitalizationTests() + { + // TODO uncomment below to create an instance of Capitalization + //instance = new Capitalization(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Capitalization + /// + [Fact] + public void CapitalizationInstanceTest() + { + // TODO uncomment below to test "IsType" Capitalization + //Assert.IsType(instance); + } + + /// + /// Test the property 'ATT_NAME' + /// + [Fact] + public void ATT_NAMETest() + { + // TODO unit test for the property 'ATT_NAME' + } + + /// + /// Test the property 'CapitalCamel' + /// + [Fact] + public void CapitalCamelTest() + { + // TODO unit test for the property 'CapitalCamel' + } + + /// + /// Test the property 'CapitalSnake' + /// + [Fact] + public void CapitalSnakeTest() + { + // TODO unit test for the property 'CapitalSnake' + } + + /// + /// Test the property 'SCAETHFlowPoints' + /// + [Fact] + public void SCAETHFlowPointsTest() + { + // TODO unit test for the property 'SCAETHFlowPoints' + } + + /// + /// Test the property 'SmallCamel' + /// + [Fact] + public void SmallCamelTest() + { + // TODO unit test for the property 'SmallCamel' + } + + /// + /// Test the property 'SmallSnake' + /// + [Fact] + public void SmallSnakeTest() + { + // TODO unit test for the property 'SmallSnake' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CatTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CatTests.cs new file mode 100644 index 000000000000..a5d4bf43bbfd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CatTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Cat + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CatTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Cat + //private Cat instance; + + public CatTests() + { + // TODO uncomment below to create an instance of Cat + //instance = new Cat(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Cat + /// + [Fact] + public void CatInstanceTest() + { + // TODO uncomment below to test "IsType" Cat + //Assert.IsType(instance); + } + + /// + /// Test the property 'Declawed' + /// + [Fact] + public void DeclawedTest() + { + // TODO unit test for the property 'Declawed' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CategoryTests.cs new file mode 100644 index 000000000000..7fe8f333c81a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CategoryTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Category + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CategoryTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Category + //private Category instance; + + public CategoryTests() + { + // TODO uncomment below to create an instance of Category + //instance = new Category(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Category + /// + [Fact] + public void CategoryInstanceTest() + { + // TODO uncomment below to test "IsType" Category + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatAllOfPetTypeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatAllOfPetTypeTests.cs new file mode 100644 index 000000000000..f24fa44b0e0f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatAllOfPetTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ChildCatAllOfPetType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ChildCatAllOfPetTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ChildCatAllOfPetType + //private ChildCatAllOfPetType instance; + + public ChildCatAllOfPetTypeTests() + { + // TODO uncomment below to create an instance of ChildCatAllOfPetType + //instance = new ChildCatAllOfPetType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ChildCatAllOfPetType + /// + [Fact] + public void ChildCatAllOfPetTypeInstanceTest() + { + // TODO uncomment below to test "IsType" ChildCatAllOfPetType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs new file mode 100644 index 000000000000..4aecdf9bed37 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ChildCat + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ChildCatTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ChildCat + //private ChildCat instance; + + public ChildCatTests() + { + // TODO uncomment below to create an instance of ChildCat + //instance = new ChildCat(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ChildCat + /// + [Fact] + public void ChildCatInstanceTest() + { + // TODO uncomment below to test "IsType" ChildCat + //Assert.IsType(instance); + } + + /// + /// Test the property 'PetType' + /// + [Fact] + public void PetTypeTest() + { + // TODO unit test for the property 'PetType' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs new file mode 100644 index 000000000000..a866bfbe242d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ClassModel + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ClassModelTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ClassModel + //private ClassModel instance; + + public ClassModelTests() + { + // TODO uncomment below to create an instance of ClassModel + //instance = new ClassModel(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ClassModel + /// + [Fact] + public void ClassModelInstanceTest() + { + // TODO uncomment below to test "IsType" ClassModel + //Assert.IsType(instance); + } + + /// + /// Test the property 'Class' + /// + [Fact] + public void ClassTest() + { + // TODO unit test for the property 'Class' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs new file mode 100644 index 000000000000..a7a864154acf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ComplexQuadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ComplexQuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ComplexQuadrilateral + //private ComplexQuadrilateral instance; + + public ComplexQuadrilateralTests() + { + // TODO uncomment below to create an instance of ComplexQuadrilateral + //instance = new ComplexQuadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ComplexQuadrilateral + /// + [Fact] + public void ComplexQuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" ComplexQuadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs new file mode 100644 index 000000000000..e7c505b5136d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DanishPig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DanishPigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DanishPig + //private DanishPig instance; + + public DanishPigTests() + { + // TODO uncomment below to create an instance of DanishPig + //instance = new DanishPig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DanishPig + /// + [Fact] + public void DanishPigInstanceTest() + { + // TODO uncomment below to test "IsType" DanishPig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..83a4185e53d2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs new file mode 100644 index 000000000000..95e56f782da3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DeprecatedObject + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DeprecatedObjectTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DeprecatedObject + //private DeprecatedObject instance; + + public DeprecatedObjectTests() + { + // TODO uncomment below to create an instance of DeprecatedObject + //instance = new DeprecatedObject(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DeprecatedObject + /// + [Fact] + public void DeprecatedObjectInstanceTest() + { + // TODO uncomment below to test "IsType" DeprecatedObject + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DogTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DogTests.cs new file mode 100644 index 000000000000..b8e8bca05384 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DogTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Dog + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DogTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Dog + //private Dog instance; + + public DogTests() + { + // TODO uncomment below to create an instance of Dog + //instance = new Dog(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Dog + /// + [Fact] + public void DogInstanceTest() + { + // TODO uncomment below to test "IsType" Dog + //Assert.IsType(instance); + } + + /// + /// Test the property 'Breed' + /// + [Fact] + public void BreedTest() + { + // TODO unit test for the property 'Breed' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DrawingTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DrawingTests.cs new file mode 100644 index 000000000000..a2de4a1b97b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/DrawingTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Drawing + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DrawingTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Drawing + //private Drawing instance; + + public DrawingTests() + { + // TODO uncomment below to create an instance of Drawing + //instance = new Drawing(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Drawing + /// + [Fact] + public void DrawingInstanceTest() + { + // TODO uncomment below to test "IsType" Drawing + //Assert.IsType(instance); + } + + /// + /// Test the property 'MainShape' + /// + [Fact] + public void MainShapeTest() + { + // TODO unit test for the property 'MainShape' + } + + /// + /// Test the property 'NullableShape' + /// + [Fact] + public void NullableShapeTest() + { + // TODO unit test for the property 'NullableShape' + } + + /// + /// Test the property 'ShapeOrNull' + /// + [Fact] + public void ShapeOrNullTest() + { + // TODO unit test for the property 'ShapeOrNull' + } + + /// + /// Test the property 'Shapes' + /// + [Fact] + public void ShapesTest() + { + // TODO unit test for the property 'Shapes' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysArrayEnumInnerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysArrayEnumInnerTests.cs new file mode 100644 index 000000000000..131ed18d63fd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysArrayEnumInnerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumArraysArrayEnumInner + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumArraysArrayEnumInnerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumArraysArrayEnumInner + //private EnumArraysArrayEnumInner instance; + + public EnumArraysArrayEnumInnerTests() + { + // TODO uncomment below to create an instance of EnumArraysArrayEnumInner + //instance = new EnumArraysArrayEnumInner(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumArraysArrayEnumInner + /// + [Fact] + public void EnumArraysArrayEnumInnerInstanceTest() + { + // TODO uncomment below to test "IsType" EnumArraysArrayEnumInner + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysJustSymbolTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysJustSymbolTests.cs new file mode 100644 index 000000000000..98fb4af3a1ce --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysJustSymbolTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumArraysJustSymbol + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumArraysJustSymbolTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumArraysJustSymbol + //private EnumArraysJustSymbol instance; + + public EnumArraysJustSymbolTests() + { + // TODO uncomment below to create an instance of EnumArraysJustSymbol + //instance = new EnumArraysJustSymbol(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumArraysJustSymbol + /// + [Fact] + public void EnumArraysJustSymbolInstanceTest() + { + // TODO uncomment below to test "IsType" EnumArraysJustSymbol + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs new file mode 100644 index 000000000000..c6fee27690b7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumArrays + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumArraysTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumArrays + //private EnumArrays instance; + + public EnumArraysTests() + { + // TODO uncomment below to create an instance of EnumArrays + //instance = new EnumArrays(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumArrays + /// + [Fact] + public void EnumArraysInstanceTest() + { + // TODO uncomment below to test "IsType" EnumArrays + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayEnum' + /// + [Fact] + public void ArrayEnumTest() + { + // TODO unit test for the property 'ArrayEnum' + } + + /// + /// Test the property 'JustSymbol' + /// + [Fact] + public void JustSymbolTest() + { + // TODO unit test for the property 'JustSymbol' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs new file mode 100644 index 000000000000..44dbbe4d324a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumClass + //private EnumClass instance; + + public EnumClassTests() + { + // TODO uncomment below to create an instance of EnumClass + //instance = new EnumClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumClass + /// + [Fact] + public void EnumClassInstanceTest() + { + // TODO uncomment below to test "IsType" EnumClass + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerOnlyTests.cs new file mode 100644 index 000000000000..5354a6a395c7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerOnlyTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumTestEnumIntegerOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumTestEnumIntegerOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumTestEnumIntegerOnly + //private EnumTestEnumIntegerOnly instance; + + public EnumTestEnumIntegerOnlyTests() + { + // TODO uncomment below to create an instance of EnumTestEnumIntegerOnly + //instance = new EnumTestEnumIntegerOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumTestEnumIntegerOnly + /// + [Fact] + public void EnumTestEnumIntegerOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" EnumTestEnumIntegerOnly + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerTests.cs new file mode 100644 index 000000000000..da32ebb09ad8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumIntegerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumTestEnumInteger + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumTestEnumIntegerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumTestEnumInteger + //private EnumTestEnumInteger instance; + + public EnumTestEnumIntegerTests() + { + // TODO uncomment below to create an instance of EnumTestEnumInteger + //instance = new EnumTestEnumInteger(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumTestEnumInteger + /// + [Fact] + public void EnumTestEnumIntegerInstanceTest() + { + // TODO uncomment below to test "IsType" EnumTestEnumInteger + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumStringTests.cs new file mode 100644 index 000000000000..02321eb5de63 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestEnumStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumTestEnumString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumTestEnumStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumTestEnumString + //private EnumTestEnumString instance; + + public EnumTestEnumStringTests() + { + // TODO uncomment below to create an instance of EnumTestEnumString + //instance = new EnumTestEnumString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumTestEnumString + /// + [Fact] + public void EnumTestEnumStringInstanceTest() + { + // TODO uncomment below to test "IsType" EnumTestEnumString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs new file mode 100644 index 000000000000..3781eebbfcf2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs @@ -0,0 +1,137 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumTest + //private EnumTest instance; + + public EnumTestTests() + { + // TODO uncomment below to create an instance of EnumTest + //instance = new EnumTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumTest + /// + [Fact] + public void EnumTestInstanceTest() + { + // TODO uncomment below to test "IsType" EnumTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'EnumStringRequired' + /// + [Fact] + public void EnumStringRequiredTest() + { + // TODO unit test for the property 'EnumStringRequired' + } + + /// + /// Test the property 'EnumInteger' + /// + [Fact] + public void EnumIntegerTest() + { + // TODO unit test for the property 'EnumInteger' + } + + /// + /// Test the property 'EnumIntegerOnly' + /// + [Fact] + public void EnumIntegerOnlyTest() + { + // TODO unit test for the property 'EnumIntegerOnly' + } + + /// + /// Test the property 'EnumNumber' + /// + [Fact] + public void EnumNumberTest() + { + // TODO unit test for the property 'EnumNumber' + } + + /// + /// Test the property 'EnumString' + /// + [Fact] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + + /// + /// Test the property 'OuterEnum' + /// + [Fact] + public void OuterEnumTest() + { + // TODO unit test for the property 'OuterEnum' + } + + /// + /// Test the property 'OuterEnumDefaultValue' + /// + [Fact] + public void OuterEnumDefaultValueTest() + { + // TODO unit test for the property 'OuterEnumDefaultValue' + } + + /// + /// Test the property 'OuterEnumInteger' + /// + [Fact] + public void OuterEnumIntegerTest() + { + // TODO unit test for the property 'OuterEnumInteger' + } + + /// + /// Test the property 'OuterEnumIntegerDefaultValue' + /// + [Fact] + public void OuterEnumIntegerDefaultValueTest() + { + // TODO unit test for the property 'OuterEnumIntegerDefaultValue' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs new file mode 100644 index 000000000000..f8d3daec3fe1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EquilateralTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EquilateralTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EquilateralTriangle + //private EquilateralTriangle instance; + + public EquilateralTriangleTests() + { + // TODO uncomment below to create an instance of EquilateralTriangle + //instance = new EquilateralTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EquilateralTriangle + /// + [Fact] + public void EquilateralTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" EquilateralTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs new file mode 100644 index 000000000000..e2685848d5ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FileSchemaTestClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FileSchemaTestClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FileSchemaTestClass + //private FileSchemaTestClass instance; + + public FileSchemaTestClassTests() + { + // TODO uncomment below to create an instance of FileSchemaTestClass + //instance = new FileSchemaTestClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FileSchemaTestClass + /// + [Fact] + public void FileSchemaTestClassInstanceTest() + { + // TODO uncomment below to test "IsType" FileSchemaTestClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'File' + /// + [Fact] + public void FileTest() + { + // TODO unit test for the property 'File' + } + + /// + /// Test the property 'Files' + /// + [Fact] + public void FilesTest() + { + // TODO unit test for the property 'Files' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileTests.cs new file mode 100644 index 000000000000..c305c5356b05 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FileTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing File + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FileTests : IDisposable + { + // TODO uncomment below to declare an instance variable for File + //private File instance; + + public FileTests() + { + // TODO uncomment below to create an instance of File + //instance = new File(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of File + /// + [Fact] + public void FileInstanceTest() + { + // TODO uncomment below to test "IsType" File + //Assert.IsType(instance); + } + + /// + /// Test the property 'SourceURI' + /// + [Fact] + public void SourceURITest() + { + // TODO unit test for the property 'SourceURI' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FindPetsByStatusStatusParameterInnerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FindPetsByStatusStatusParameterInnerTests.cs new file mode 100644 index 000000000000..33d0a40c8032 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FindPetsByStatusStatusParameterInnerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FindPetsByStatusStatusParameterInner + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FindPetsByStatusStatusParameterInnerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FindPetsByStatusStatusParameterInner + //private FindPetsByStatusStatusParameterInner instance; + + public FindPetsByStatusStatusParameterInnerTests() + { + // TODO uncomment below to create an instance of FindPetsByStatusStatusParameterInner + //instance = new FindPetsByStatusStatusParameterInner(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FindPetsByStatusStatusParameterInner + /// + [Fact] + public void FindPetsByStatusStatusParameterInnerInstanceTest() + { + // TODO uncomment below to test "IsType" FindPetsByStatusStatusParameterInner + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs new file mode 100644 index 000000000000..55086a7cf24b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FooGetDefaultResponse + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FooGetDefaultResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FooGetDefaultResponse + //private FooGetDefaultResponse instance; + + public FooGetDefaultResponseTests() + { + // TODO uncomment below to create an instance of FooGetDefaultResponse + //instance = new FooGetDefaultResponse(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FooGetDefaultResponse + /// + [Fact] + public void FooGetDefaultResponseInstanceTest() + { + // TODO uncomment below to test "IsType" FooGetDefaultResponse + //Assert.IsType(instance); + } + + /// + /// Test the property 'String' + /// + [Fact] + public void StringTest() + { + // TODO unit test for the property 'String' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooTests.cs new file mode 100644 index 000000000000..871506eeaac5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FooTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Foo + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FooTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Foo + //private Foo instance; + + public FooTests() + { + // TODO uncomment below to create an instance of Foo + //instance = new Foo(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Foo + /// + [Fact] + public void FooInstanceTest() + { + // TODO uncomment below to test "IsType" Foo + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs new file mode 100644 index 000000000000..b658f317f1ce --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs @@ -0,0 +1,227 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FormatTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FormatTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FormatTest + //private FormatTest instance; + + public FormatTestTests() + { + // TODO uncomment below to create an instance of FormatTest + //instance = new FormatTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FormatTest + /// + [Fact] + public void FormatTestInstanceTest() + { + // TODO uncomment below to test "IsType" FormatTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'Byte' + /// + [Fact] + public void ByteTest() + { + // TODO unit test for the property 'Byte' + } + + /// + /// Test the property 'Date' + /// + [Fact] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + + /// + /// Test the property 'Number' + /// + [Fact] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + + /// + /// Test the property 'Binary' + /// + [Fact] + public void BinaryTest() + { + // TODO unit test for the property 'Binary' + } + + /// + /// Test the property 'DateTime' + /// + [Fact] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + + /// + /// Test the property 'Decimal' + /// + [Fact] + public void DecimalTest() + { + // TODO unit test for the property 'Decimal' + } + + /// + /// Test the property 'Double' + /// + [Fact] + public void DoubleTest() + { + // TODO unit test for the property 'Double' + } + + /// + /// Test the property 'Float' + /// + [Fact] + public void FloatTest() + { + // TODO unit test for the property 'Float' + } + + /// + /// Test the property 'Int32' + /// + [Fact] + public void Int32Test() + { + // TODO unit test for the property 'Int32' + } + + /// + /// Test the property 'Int64' + /// + [Fact] + public void Int64Test() + { + // TODO unit test for the property 'Int64' + } + + /// + /// Test the property 'Integer' + /// + [Fact] + public void IntegerTest() + { + // TODO unit test for the property 'Integer' + } + + /// + /// Test the property 'PatternWithBackslash' + /// + [Fact] + public void PatternWithBackslashTest() + { + // TODO unit test for the property 'PatternWithBackslash' + } + + /// + /// Test the property 'PatternWithDigits' + /// + [Fact] + public void PatternWithDigitsTest() + { + // TODO unit test for the property 'PatternWithDigits' + } + + /// + /// Test the property 'PatternWithDigitsAndDelimiter' + /// + [Fact] + public void PatternWithDigitsAndDelimiterTest() + { + // TODO unit test for the property 'PatternWithDigitsAndDelimiter' + } + + /// + /// Test the property 'String' + /// + [Fact] + public void StringTest() + { + // TODO unit test for the property 'String' + } + + /// + /// Test the property 'UnsignedInteger' + /// + [Fact] + public void UnsignedIntegerTest() + { + // TODO unit test for the property 'UnsignedInteger' + } + + /// + /// Test the property 'UnsignedLong' + /// + [Fact] + public void UnsignedLongTest() + { + // TODO unit test for the property 'UnsignedLong' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs new file mode 100644 index 000000000000..a33c55ae4875 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FruitReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FruitReq + //private FruitReq instance; + + public FruitReqTests() + { + // TODO uncomment below to create an instance of FruitReq + //instance = new FruitReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FruitReq + /// + [Fact] + public void FruitReqInstanceTest() + { + // TODO uncomment below to test "IsType" FruitReq + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitTests.cs new file mode 100644 index 000000000000..46448efc62f4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Fruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Fruit + //private Fruit instance; + + public FruitTests() + { + // TODO uncomment below to create an instance of Fruit + //instance = new Fruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Fruit + /// + [Fact] + public void FruitInstanceTest() + { + // TODO uncomment below to test "IsType" Fruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs new file mode 100644 index 000000000000..7e79cd067925 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing GmFruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class GmFruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for GmFruit + //private GmFruit instance; + + public GmFruitTests() + { + // TODO uncomment below to create an instance of GmFruit + //instance = new GmFruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of GmFruit + /// + [Fact] + public void GmFruitInstanceTest() + { + // TODO uncomment below to test "IsType" GmFruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs new file mode 100644 index 000000000000..5f0e8672ed5f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing GrandparentAnimal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class GrandparentAnimalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for GrandparentAnimal + //private GrandparentAnimal instance; + + public GrandparentAnimalTests() + { + // TODO uncomment below to create an instance of GrandparentAnimal + //instance = new GrandparentAnimal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of GrandparentAnimal + /// + [Fact] + public void GrandparentAnimalInstanceTest() + { + // TODO uncomment below to test "IsType" GrandparentAnimal + //Assert.IsType(instance); + } + + /// + /// Test deserialize a ChildCat from type ParentPet + /// + [Fact] + public void ChildCatDeserializeFromParentPetTest() + { + // TODO uncomment below to test deserialize a ChildCat from type ParentPet + //Assert.IsType(JsonConvert.DeserializeObject(new ChildCat().ToJson())); + } + + /// + /// Test deserialize a ParentPet from type GrandparentAnimal + /// + [Fact] + public void ParentPetDeserializeFromGrandparentAnimalTest() + { + // TODO uncomment below to test deserialize a ParentPet from type GrandparentAnimal + //Assert.IsType(JsonConvert.DeserializeObject(new ParentPet().ToJson())); + } + + /// + /// Test the property 'PetType' + /// + [Fact] + public void PetTypeTest() + { + // TODO unit test for the property 'PetType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs new file mode 100644 index 000000000000..134a7d515ebb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing HasOnlyReadOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class HasOnlyReadOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for HasOnlyReadOnly + //private HasOnlyReadOnly instance; + + public HasOnlyReadOnlyTests() + { + // TODO uncomment below to create an instance of HasOnlyReadOnly + //instance = new HasOnlyReadOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of HasOnlyReadOnly + /// + [Fact] + public void HasOnlyReadOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" HasOnlyReadOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + + /// + /// Test the property 'Foo' + /// + [Fact] + public void FooTest() + { + // TODO unit test for the property 'Foo' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs new file mode 100644 index 000000000000..18bb8672e980 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing HealthCheckResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class HealthCheckResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for HealthCheckResult + //private HealthCheckResult instance; + + public HealthCheckResultTests() + { + // TODO uncomment below to create an instance of HealthCheckResult + //instance = new HealthCheckResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of HealthCheckResult + /// + [Fact] + public void HealthCheckResultInstanceTest() + { + // TODO uncomment below to test "IsType" HealthCheckResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'NullableMessage' + /// + [Fact] + public void NullableMessageTest() + { + // TODO unit test for the property 'NullableMessage' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs new file mode 100644 index 000000000000..464750233cd2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing IsoscelesTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class IsoscelesTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for IsoscelesTriangle + //private IsoscelesTriangle instance; + + public IsoscelesTriangleTests() + { + // TODO uncomment below to create an instance of IsoscelesTriangle + //instance = new IsoscelesTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of IsoscelesTriangle + /// + [Fact] + public void IsoscelesTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" IsoscelesTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ListTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ListTests.cs new file mode 100644 index 000000000000..d95303d97517 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ListTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing List + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ListTests : IDisposable + { + // TODO uncomment below to declare an instance variable for List + //private List instance; + + public ListTests() + { + // TODO uncomment below to create an instance of List + //instance = new List(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of List + /// + [Fact] + public void ListInstanceTest() + { + // TODO uncomment below to test "IsType" List + //Assert.IsType(instance); + } + + /// + /// Test the property 'Var123List' + /// + [Fact] + public void Var123ListTest() + { + // TODO unit test for the property 'Var123List' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs new file mode 100644 index 000000000000..31d21de5b60c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing LiteralStringClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class LiteralStringClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for LiteralStringClass + //private LiteralStringClass instance; + + public LiteralStringClassTests() + { + // TODO uncomment below to create an instance of LiteralStringClass + //instance = new LiteralStringClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of LiteralStringClass + /// + [Fact] + public void LiteralStringClassInstanceTest() + { + // TODO uncomment below to test "IsType" LiteralStringClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'EscapedLiteralString' + /// + [Fact] + public void EscapedLiteralStringTest() + { + // TODO unit test for the property 'EscapedLiteralString' + } + + /// + /// Test the property 'UnescapedLiteralString' + /// + [Fact] + public void UnescapedLiteralStringTest() + { + // TODO unit test for the property 'UnescapedLiteralString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MammalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MammalTests.cs new file mode 100644 index 000000000000..64bd9e890343 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MammalTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Mammal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MammalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Mammal + //private Mammal instance; + + public MammalTests() + { + // TODO uncomment below to create an instance of Mammal + //instance = new Mammal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Mammal + /// + [Fact] + public void MammalInstanceTest() + { + // TODO uncomment below to test "IsType" Mammal + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestMapOfEnumStringValueTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestMapOfEnumStringValueTests.cs new file mode 100644 index 000000000000..37713bb0496d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestMapOfEnumStringValueTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MapTestMapOfEnumStringValue + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MapTestMapOfEnumStringValueTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MapTestMapOfEnumStringValue + //private MapTestMapOfEnumStringValue instance; + + public MapTestMapOfEnumStringValueTests() + { + // TODO uncomment below to create an instance of MapTestMapOfEnumStringValue + //instance = new MapTestMapOfEnumStringValue(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MapTestMapOfEnumStringValue + /// + [Fact] + public void MapTestMapOfEnumStringValueInstanceTest() + { + // TODO uncomment below to test "IsType" MapTestMapOfEnumStringValue + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestTests.cs new file mode 100644 index 000000000000..2dc6d8d8e04b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MapTestTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MapTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MapTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MapTest + //private MapTest instance; + + public MapTestTests() + { + // TODO uncomment below to create an instance of MapTest + //instance = new MapTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MapTest + /// + [Fact] + public void MapTestInstanceTest() + { + // TODO uncomment below to test "IsType" MapTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'DirectMap' + /// + [Fact] + public void DirectMapTest() + { + // TODO unit test for the property 'DirectMap' + } + + /// + /// Test the property 'IndirectMap' + /// + [Fact] + public void IndirectMapTest() + { + // TODO unit test for the property 'IndirectMap' + } + + /// + /// Test the property 'MapMapOfString' + /// + [Fact] + public void MapMapOfStringTest() + { + // TODO unit test for the property 'MapMapOfString' + } + + /// + /// Test the property 'MapOfEnumString' + /// + [Fact] + public void MapOfEnumStringTest() + { + // TODO unit test for the property 'MapOfEnumString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixLogTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixLogTests.cs new file mode 100644 index 000000000000..3f108758fd2e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixLogTests.cs @@ -0,0 +1,344 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixLog + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixLogTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixLog + //private MixLog instance; + + public MixLogTests() + { + // TODO uncomment below to create an instance of MixLog + //instance = new MixLog(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixLog + /// + [Fact] + public void MixLogInstanceTest() + { + // TODO uncomment below to test "IsType" MixLog + //Assert.IsType(instance); + } + + /// + /// Test the property 'Description' + /// + [Fact] + public void DescriptionTest() + { + // TODO unit test for the property 'Description' + } + + /// + /// Test the property 'FormulaVersionDate' + /// + [Fact] + public void FormulaVersionDateTest() + { + // TODO unit test for the property 'FormulaVersionDate' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'MixDate' + /// + [Fact] + public void MixDateTest() + { + // TODO unit test for the property 'MixDate' + } + + /// + /// Test the property 'TotalOverPoors' + /// + [Fact] + public void TotalOverPoorsTest() + { + // TODO unit test for the property 'TotalOverPoors' + } + + /// + /// Test the property 'TotalRecalculations' + /// + [Fact] + public void TotalRecalculationsTest() + { + // TODO unit test for the property 'TotalRecalculations' + } + + /// + /// Test the property 'TotalSkips' + /// + [Fact] + public void TotalSkipsTest() + { + // TODO unit test for the property 'TotalSkips' + } + + /// + /// Test the property 'TotalUnderPours' + /// + [Fact] + public void TotalUnderPoursTest() + { + // TODO unit test for the property 'TotalUnderPours' + } + + /// + /// Test the property 'BatchNumber' + /// + [Fact] + public void BatchNumberTest() + { + // TODO unit test for the property 'BatchNumber' + } + + /// + /// Test the property 'BrandCode' + /// + [Fact] + public void BrandCodeTest() + { + // TODO unit test for the property 'BrandCode' + } + + /// + /// Test the property 'BrandId' + /// + [Fact] + public void BrandIdTest() + { + // TODO unit test for the property 'BrandId' + } + + /// + /// Test the property 'BrandName' + /// + [Fact] + public void BrandNameTest() + { + // TODO unit test for the property 'BrandName' + } + + /// + /// Test the property 'CategoryCode' + /// + [Fact] + public void CategoryCodeTest() + { + // TODO unit test for the property 'CategoryCode' + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + + /// + /// Test the property 'ColorDescription' + /// + [Fact] + public void ColorDescriptionTest() + { + // TODO unit test for the property 'ColorDescription' + } + + /// + /// Test the property 'Comment' + /// + [Fact] + public void CommentTest() + { + // TODO unit test for the property 'Comment' + } + + /// + /// Test the property 'CommercialProductCode' + /// + [Fact] + public void CommercialProductCodeTest() + { + // TODO unit test for the property 'CommercialProductCode' + } + + /// + /// Test the property 'Country' + /// + [Fact] + public void CountryTest() + { + // TODO unit test for the property 'Country' + } + + /// + /// Test the property 'CreatedBy' + /// + [Fact] + public void CreatedByTest() + { + // TODO unit test for the property 'CreatedBy' + } + + /// + /// Test the property 'CreatedByFirstName' + /// + [Fact] + public void CreatedByFirstNameTest() + { + // TODO unit test for the property 'CreatedByFirstName' + } + + /// + /// Test the property 'CreatedByLastName' + /// + [Fact] + public void CreatedByLastNameTest() + { + // TODO unit test for the property 'CreatedByLastName' + } + + /// + /// Test the property 'DeltaECalculationRepaired' + /// + [Fact] + public void DeltaECalculationRepairedTest() + { + // TODO unit test for the property 'DeltaECalculationRepaired' + } + + /// + /// Test the property 'DeltaECalculationSprayout' + /// + [Fact] + public void DeltaECalculationSprayoutTest() + { + // TODO unit test for the property 'DeltaECalculationSprayout' + } + + /// + /// Test the property 'OwnColorVariantNumber' + /// + [Fact] + public void OwnColorVariantNumberTest() + { + // TODO unit test for the property 'OwnColorVariantNumber' + } + + /// + /// Test the property 'PrimerProductId' + /// + [Fact] + public void PrimerProductIdTest() + { + // TODO unit test for the property 'PrimerProductId' + } + + /// + /// Test the property 'ProductId' + /// + [Fact] + public void ProductIdTest() + { + // TODO unit test for the property 'ProductId' + } + + /// + /// Test the property 'ProductLineCode' + /// + [Fact] + public void ProductLineCodeTest() + { + // TODO unit test for the property 'ProductLineCode' + } + + /// + /// Test the property 'ProductName' + /// + [Fact] + public void ProductNameTest() + { + // TODO unit test for the property 'ProductName' + } + + /// + /// Test the property 'SelectedVersionIndex' + /// + [Fact] + public void SelectedVersionIndexTest() + { + // TODO unit test for the property 'SelectedVersionIndex' + } + + /// + /// Test the property 'ShopId' + /// + [Fact] + public void ShopIdTest() + { + // TODO unit test for the property 'ShopId' + } + + /// + /// Test the property 'SomeCode' + /// + [Fact] + public void SomeCodeTest() + { + // TODO unit test for the property 'SomeCode' + } + + /// + /// Test the property 'TotalPrice' + /// + [Fact] + public void TotalPriceTest() + { + // TODO unit test for the property 'TotalPrice' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs new file mode 100644 index 000000000000..d3689c15f401 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedPropertiesAndAdditionalPropertiesClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedPropertiesAndAdditionalPropertiesClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedPropertiesAndAdditionalPropertiesClass + //private MixedPropertiesAndAdditionalPropertiesClass instance; + + public MixedPropertiesAndAdditionalPropertiesClassTests() + { + // TODO uncomment below to create an instance of MixedPropertiesAndAdditionalPropertiesClass + //instance = new MixedPropertiesAndAdditionalPropertiesClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedPropertiesAndAdditionalPropertiesClass + /// + [Fact] + public void MixedPropertiesAndAdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsType" MixedPropertiesAndAdditionalPropertiesClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'DateTime' + /// + [Fact] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + + /// + /// Test the property 'Map' + /// + [Fact] + public void MapTest() + { + // TODO unit test for the property 'Map' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'UuidWithPattern' + /// + [Fact] + public void UuidWithPatternTest() + { + // TODO unit test for the property 'UuidWithPattern' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs new file mode 100644 index 000000000000..3b5e94c5f8f3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Model200Response + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class Model200ResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Model200Response + //private Model200Response instance; + + public Model200ResponseTests() + { + // TODO uncomment below to create an instance of Model200Response + //instance = new Model200Response(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Model200Response + /// + [Fact] + public void Model200ResponseInstanceTest() + { + // TODO uncomment below to test "IsType" Model200Response + //Assert.IsType(instance); + } + + /// + /// Test the property 'Class' + /// + [Fact] + public void ClassTest() + { + // TODO unit test for the property 'Class' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs new file mode 100644 index 000000000000..5a986cfdc6c2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ModelClient + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ModelClientTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ModelClient + //private ModelClient instance; + + public ModelClientTests() + { + // TODO uncomment below to create an instance of ModelClient + //instance = new ModelClient(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ModelClient + /// + [Fact] + public void ModelClientInstanceTest() + { + // TODO uncomment below to test "IsType" ModelClient + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarClient' + /// + [Fact] + public void VarClientTest() + { + // TODO unit test for the property 'VarClient' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NameTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NameTests.cs new file mode 100644 index 000000000000..3aac92ae4683 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NameTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Name + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NameTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Name + //private Name instance; + + public NameTests() + { + // TODO uncomment below to create an instance of Name + //instance = new Name(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Name + /// + [Fact] + public void NameInstanceTest() + { + // TODO uncomment below to test "IsType" Name + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarName' + /// + [Fact] + public void VarNameTest() + { + // TODO unit test for the property 'VarName' + } + + /// + /// Test the property 'Property' + /// + [Fact] + public void PropertyTest() + { + // TODO unit test for the property 'Property' + } + + /// + /// Test the property 'SnakeCase' + /// + [Fact] + public void SnakeCaseTest() + { + // TODO unit test for the property 'SnakeCase' + } + + /// + /// Test the property 'Var123Number' + /// + [Fact] + public void Var123NumberTest() + { + // TODO unit test for the property 'Var123Number' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs new file mode 100644 index 000000000000..dd3b74e33061 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NotificationtestGetElementsV1ResponseMPayload + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NotificationtestGetElementsV1ResponseMPayloadTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NotificationtestGetElementsV1ResponseMPayload + //private NotificationtestGetElementsV1ResponseMPayload instance; + + public NotificationtestGetElementsV1ResponseMPayloadTests() + { + // TODO uncomment below to create an instance of NotificationtestGetElementsV1ResponseMPayload + //instance = new NotificationtestGetElementsV1ResponseMPayload(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NotificationtestGetElementsV1ResponseMPayload + /// + [Fact] + public void NotificationtestGetElementsV1ResponseMPayloadInstanceTest() + { + // TODO uncomment below to test "IsType" NotificationtestGetElementsV1ResponseMPayload + //Assert.IsType(instance); + } + + /// + /// Test the property 'AObjVariableobject' + /// + [Fact] + public void AObjVariableobjectTest() + { + // TODO unit test for the property 'AObjVariableobject' + } + + /// + /// Test the property 'PkiNotificationtestID' + /// + [Fact] + public void PkiNotificationtestIDTest() + { + // TODO unit test for the property 'PkiNotificationtestID' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs new file mode 100644 index 000000000000..1e19aa6b8231 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs @@ -0,0 +1,164 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableClass + //private NullableClass instance; + + public NullableClassTests() + { + // TODO uncomment below to create an instance of NullableClass + //instance = new NullableClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableClass + /// + [Fact] + public void NullableClassInstanceTest() + { + // TODO uncomment below to test "IsType" NullableClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayAndItemsNullableProp' + /// + [Fact] + public void ArrayAndItemsNullablePropTest() + { + // TODO unit test for the property 'ArrayAndItemsNullableProp' + } + + /// + /// Test the property 'ArrayItemsNullable' + /// + [Fact] + public void ArrayItemsNullableTest() + { + // TODO unit test for the property 'ArrayItemsNullable' + } + + /// + /// Test the property 'ArrayNullableProp' + /// + [Fact] + public void ArrayNullablePropTest() + { + // TODO unit test for the property 'ArrayNullableProp' + } + + /// + /// Test the property 'BooleanProp' + /// + [Fact] + public void BooleanPropTest() + { + // TODO unit test for the property 'BooleanProp' + } + + /// + /// Test the property 'DateProp' + /// + [Fact] + public void DatePropTest() + { + // TODO unit test for the property 'DateProp' + } + + /// + /// Test the property 'DatetimeProp' + /// + [Fact] + public void DatetimePropTest() + { + // TODO unit test for the property 'DatetimeProp' + } + + /// + /// Test the property 'IntegerProp' + /// + [Fact] + public void IntegerPropTest() + { + // TODO unit test for the property 'IntegerProp' + } + + /// + /// Test the property 'NumberProp' + /// + [Fact] + public void NumberPropTest() + { + // TODO unit test for the property 'NumberProp' + } + + /// + /// Test the property 'ObjectAndItemsNullableProp' + /// + [Fact] + public void ObjectAndItemsNullablePropTest() + { + // TODO unit test for the property 'ObjectAndItemsNullableProp' + } + + /// + /// Test the property 'ObjectItemsNullable' + /// + [Fact] + public void ObjectItemsNullableTest() + { + // TODO unit test for the property 'ObjectItemsNullable' + } + + /// + /// Test the property 'ObjectNullableProp' + /// + [Fact] + public void ObjectNullablePropTest() + { + // TODO unit test for the property 'ObjectNullableProp' + } + + /// + /// Test the property 'StringProp' + /// + [Fact] + public void StringPropTest() + { + // TODO unit test for the property 'StringProp' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs new file mode 100644 index 000000000000..db8c9aa09568 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableGuidClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableGuidClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableGuidClass + //private NullableGuidClass instance; + + public NullableGuidClassTests() + { + // TODO uncomment below to create an instance of NullableGuidClass + //instance = new NullableGuidClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableGuidClass + /// + [Fact] + public void NullableGuidClassInstanceTest() + { + // TODO uncomment below to test "IsType" NullableGuidClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs new file mode 100644 index 000000000000..e65ba44efa2e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableShape + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableShapeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableShape + //private NullableShape instance; + + public NullableShapeTests() + { + // TODO uncomment below to create an instance of NullableShape + //instance = new NullableShape(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableShape + /// + [Fact] + public void NullableShapeInstanceTest() + { + // TODO uncomment below to test "IsType" NullableShape + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs new file mode 100644 index 000000000000..2b88fb1a609e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NumberOnly + //private NumberOnly instance; + + public NumberOnlyTests() + { + // TODO uncomment below to create an instance of NumberOnly + //instance = new NumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NumberOnly + /// + [Fact] + public void NumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" NumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'JustNumber' + /// + [Fact] + public void JustNumberTest() + { + // TODO unit test for the property 'JustNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs new file mode 100644 index 000000000000..078655aaba70 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ObjectWithDeprecatedFields + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ObjectWithDeprecatedFieldsTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ObjectWithDeprecatedFields + //private ObjectWithDeprecatedFields instance; + + public ObjectWithDeprecatedFieldsTests() + { + // TODO uncomment below to create an instance of ObjectWithDeprecatedFields + //instance = new ObjectWithDeprecatedFields(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ObjectWithDeprecatedFields + /// + [Fact] + public void ObjectWithDeprecatedFieldsInstanceTest() + { + // TODO uncomment below to test "IsType" ObjectWithDeprecatedFields + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bars' + /// + [Fact] + public void BarsTest() + { + // TODO unit test for the property 'Bars' + } + + /// + /// Test the property 'DeprecatedRef' + /// + [Fact] + public void DeprecatedRefTest() + { + // TODO unit test for the property 'DeprecatedRef' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs new file mode 100644 index 000000000000..8ef411a15eb6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OneOfString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OneOfStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OneOfString + //private OneOfString instance; + + public OneOfStringTests() + { + // TODO uncomment below to create an instance of OneOfString + //instance = new OneOfString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OneOfString + /// + [Fact] + public void OneOfStringInstanceTest() + { + // TODO uncomment below to test "IsType" OneOfString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderStatusTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderStatusTests.cs new file mode 100644 index 000000000000..4b9bcdbbc92e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderStatusTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OrderStatus + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OrderStatusTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OrderStatus + //private OrderStatus instance; + + public OrderStatusTests() + { + // TODO uncomment below to create an instance of OrderStatus + //instance = new OrderStatus(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OrderStatus + /// + [Fact] + public void OrderStatusInstanceTest() + { + // TODO uncomment below to test "IsType" OrderStatus + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderTests.cs new file mode 100644 index 000000000000..e7187bbdc92c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OrderTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Order + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OrderTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Order + //private Order instance; + + public OrderTests() + { + // TODO uncomment below to create an instance of Order + //instance = new Order(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Order + /// + [Fact] + public void OrderInstanceTest() + { + // TODO uncomment below to test "IsType" Order + //Assert.IsType(instance); + } + + /// + /// Test the property 'Complete' + /// + [Fact] + public void CompleteTest() + { + // TODO unit test for the property 'Complete' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'PetId' + /// + [Fact] + public void PetIdTest() + { + // TODO unit test for the property 'PetId' + } + + /// + /// Test the property 'Quantity' + /// + [Fact] + public void QuantityTest() + { + // TODO unit test for the property 'Quantity' + } + + /// + /// Test the property 'ShipDate' + /// + [Fact] + public void ShipDateTest() + { + // TODO unit test for the property 'ShipDate' + } + + /// + /// Test the property 'Status' + /// + [Fact] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs new file mode 100644 index 000000000000..0bb8ce5e5d9b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterComposite + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterCompositeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterComposite + //private OuterComposite instance; + + public OuterCompositeTests() + { + // TODO uncomment below to create an instance of OuterComposite + //instance = new OuterComposite(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterComposite + /// + [Fact] + public void OuterCompositeInstanceTest() + { + // TODO uncomment below to test "IsType" OuterComposite + //Assert.IsType(instance); + } + + /// + /// Test the property 'MyBoolean' + /// + [Fact] + public void MyBooleanTest() + { + // TODO unit test for the property 'MyBoolean' + } + + /// + /// Test the property 'MyNumber' + /// + [Fact] + public void MyNumberTest() + { + // TODO unit test for the property 'MyNumber' + } + + /// + /// Test the property 'MyString' + /// + [Fact] + public void MyStringTest() + { + // TODO unit test for the property 'MyString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs new file mode 100644 index 000000000000..a1d1e1527771 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumDefaultValue + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumDefaultValueTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumDefaultValue + //private OuterEnumDefaultValue instance; + + public OuterEnumDefaultValueTests() + { + // TODO uncomment below to create an instance of OuterEnumDefaultValue + //instance = new OuterEnumDefaultValue(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumDefaultValue + /// + [Fact] + public void OuterEnumDefaultValueInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumDefaultValue + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs new file mode 100644 index 000000000000..030326d75792 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumIntegerDefaultValue + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumIntegerDefaultValueTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumIntegerDefaultValue + //private OuterEnumIntegerDefaultValue instance; + + public OuterEnumIntegerDefaultValueTests() + { + // TODO uncomment below to create an instance of OuterEnumIntegerDefaultValue + //instance = new OuterEnumIntegerDefaultValue(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumIntegerDefaultValue + /// + [Fact] + public void OuterEnumIntegerDefaultValueInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumIntegerDefaultValue + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs new file mode 100644 index 000000000000..1f3bfe459e76 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumInteger + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumIntegerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumInteger + //private OuterEnumInteger instance; + + public OuterEnumIntegerTests() + { + // TODO uncomment below to create an instance of OuterEnumInteger + //instance = new OuterEnumInteger(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumInteger + /// + [Fact] + public void OuterEnumIntegerInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumInteger + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs new file mode 100644 index 000000000000..c4cb8eeecee8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumTest + //private OuterEnumTest instance; + + public OuterEnumTestTests() + { + // TODO uncomment below to create an instance of OuterEnumTest + //instance = new OuterEnumTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumTest + /// + [Fact] + public void OuterEnumTestInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumTest + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs new file mode 100644 index 000000000000..2859494010b9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnum + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnum + //private OuterEnum instance; + + public OuterEnumTests() + { + // TODO uncomment below to create an instance of OuterEnum + //instance = new OuterEnum(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnum + /// + [Fact] + public void OuterEnumInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnum + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs new file mode 100644 index 000000000000..b0ebddd374f9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ParentPet + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ParentPetTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ParentPet + //private ParentPet instance; + + public ParentPetTests() + { + // TODO uncomment below to create an instance of ParentPet + //instance = new ParentPet(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ParentPet + /// + [Fact] + public void ParentPetInstanceTest() + { + // TODO uncomment below to test "IsType" ParentPet + //Assert.IsType(instance); + } + + /// + /// Test deserialize a ChildCat from type ParentPet + /// + [Fact] + public void ChildCatDeserializeFromParentPetTest() + { + // TODO uncomment below to test deserialize a ChildCat from type ParentPet + //Assert.IsType(JsonConvert.DeserializeObject(new ChildCat().ToJson())); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetStatusTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetStatusTests.cs new file mode 100644 index 000000000000..0b3bb9f168b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetStatusTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing PetStatus + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PetStatusTests : IDisposable + { + // TODO uncomment below to declare an instance variable for PetStatus + //private PetStatus instance; + + public PetStatusTests() + { + // TODO uncomment below to create an instance of PetStatus + //instance = new PetStatus(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of PetStatus + /// + [Fact] + public void PetStatusInstanceTest() + { + // TODO uncomment below to test "IsType" PetStatus + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetTests.cs new file mode 100644 index 000000000000..8485d1213ce6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PetTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Pet + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PetTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Pet + //private Pet instance; + + public PetTests() + { + // TODO uncomment below to create an instance of Pet + //instance = new Pet(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Pet + /// + [Fact] + public void PetInstanceTest() + { + // TODO uncomment below to test "IsType" Pet + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + + /// + /// Test the property 'PhotoUrls' + /// + [Fact] + public void PhotoUrlsTest() + { + // TODO unit test for the property 'PhotoUrls' + } + + /// + /// Test the property 'Category' + /// + [Fact] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Status' + /// + [Fact] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + + /// + /// Test the property 'Tags' + /// + [Fact] + public void TagsTest() + { + // TODO unit test for the property 'Tags' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PigTests.cs new file mode 100644 index 000000000000..bd052bc705b9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Pig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Pig + //private Pig instance; + + public PigTests() + { + // TODO uncomment below to create an instance of Pig + //instance = new Pig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Pig + /// + [Fact] + public void PigInstanceTest() + { + // TODO uncomment below to test "IsType" Pig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs new file mode 100644 index 000000000000..23120ba7bdfa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing PolymorphicProperty + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PolymorphicPropertyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for PolymorphicProperty + //private PolymorphicProperty instance; + + public PolymorphicPropertyTests() + { + // TODO uncomment below to create an instance of PolymorphicProperty + //instance = new PolymorphicProperty(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of PolymorphicProperty + /// + [Fact] + public void PolymorphicPropertyInstanceTest() + { + // TODO uncomment below to test "IsType" PolymorphicProperty + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs new file mode 100644 index 000000000000..2ddd31cfcbba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing QuadrilateralInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class QuadrilateralInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for QuadrilateralInterface + //private QuadrilateralInterface instance; + + public QuadrilateralInterfaceTests() + { + // TODO uncomment below to create an instance of QuadrilateralInterface + //instance = new QuadrilateralInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of QuadrilateralInterface + /// + [Fact] + public void QuadrilateralInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" QuadrilateralInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs new file mode 100644 index 000000000000..65673847d759 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Quadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class QuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Quadrilateral + //private Quadrilateral instance; + + public QuadrilateralTests() + { + // TODO uncomment below to create an instance of Quadrilateral + //instance = new Quadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Quadrilateral + /// + [Fact] + public void QuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" Quadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs new file mode 100644 index 000000000000..a4c91cf44a57 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ReadOnlyFirst + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ReadOnlyFirstTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ReadOnlyFirst + //private ReadOnlyFirst instance; + + public ReadOnlyFirstTests() + { + // TODO uncomment below to create an instance of ReadOnlyFirst + //instance = new ReadOnlyFirst(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ReadOnlyFirst + /// + [Fact] + public void ReadOnlyFirstInstanceTest() + { + // TODO uncomment below to test "IsType" ReadOnlyFirst + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + + /// + /// Test the property 'Baz' + /// + [Fact] + public void BazTest() + { + // TODO unit test for the property 'Baz' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerOnlyTests.cs new file mode 100644 index 000000000000..d0f0ae6b6f94 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerOnlyTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNotnullableEnumIntegerOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNotnullableEnumIntegerOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNotnullableEnumIntegerOnly + //private RequiredClassRequiredNotnullableEnumIntegerOnly instance; + + public RequiredClassRequiredNotnullableEnumIntegerOnlyTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNotnullableEnumIntegerOnly + //instance = new RequiredClassRequiredNotnullableEnumIntegerOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNotnullableEnumIntegerOnly + /// + [Fact] + public void RequiredClassRequiredNotnullableEnumIntegerOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNotnullableEnumIntegerOnly + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerTests.cs new file mode 100644 index 000000000000..60c35933cc96 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumIntegerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNotnullableEnumInteger + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNotnullableEnumIntegerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNotnullableEnumInteger + //private RequiredClassRequiredNotnullableEnumInteger instance; + + public RequiredClassRequiredNotnullableEnumIntegerTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNotnullableEnumInteger + //instance = new RequiredClassRequiredNotnullableEnumInteger(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNotnullableEnumInteger + /// + [Fact] + public void RequiredClassRequiredNotnullableEnumIntegerInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNotnullableEnumInteger + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumStringTests.cs new file mode 100644 index 000000000000..0cd9b817a017 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNotnullableEnumStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNotnullableEnumString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNotnullableEnumStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNotnullableEnumString + //private RequiredClassRequiredNotnullableEnumString instance; + + public RequiredClassRequiredNotnullableEnumStringTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNotnullableEnumString + //instance = new RequiredClassRequiredNotnullableEnumString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNotnullableEnumString + /// + [Fact] + public void RequiredClassRequiredNotnullableEnumStringInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNotnullableEnumString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerOnlyTests.cs new file mode 100644 index 000000000000..890639ce9057 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerOnlyTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNullableEnumIntegerOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNullableEnumIntegerOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNullableEnumIntegerOnly + //private RequiredClassRequiredNullableEnumIntegerOnly instance; + + public RequiredClassRequiredNullableEnumIntegerOnlyTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNullableEnumIntegerOnly + //instance = new RequiredClassRequiredNullableEnumIntegerOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNullableEnumIntegerOnly + /// + [Fact] + public void RequiredClassRequiredNullableEnumIntegerOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNullableEnumIntegerOnly + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerTests.cs new file mode 100644 index 000000000000..ed87acb3c0b6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumIntegerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNullableEnumInteger + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNullableEnumIntegerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNullableEnumInteger + //private RequiredClassRequiredNullableEnumInteger instance; + + public RequiredClassRequiredNullableEnumIntegerTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNullableEnumInteger + //instance = new RequiredClassRequiredNullableEnumInteger(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNullableEnumInteger + /// + [Fact] + public void RequiredClassRequiredNullableEnumIntegerInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNullableEnumInteger + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumStringTests.cs new file mode 100644 index 000000000000..965d4bbd2e3a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassRequiredNullableEnumStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClassRequiredNullableEnumString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassRequiredNullableEnumStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClassRequiredNullableEnumString + //private RequiredClassRequiredNullableEnumString instance; + + public RequiredClassRequiredNullableEnumStringTests() + { + // TODO uncomment below to create an instance of RequiredClassRequiredNullableEnumString + //instance = new RequiredClassRequiredNullableEnumString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClassRequiredNullableEnumString + /// + [Fact] + public void RequiredClassRequiredNullableEnumStringInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClassRequiredNullableEnumString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 000000000000..d1da68281ff0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReturnTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReturnTests.cs new file mode 100644 index 000000000000..bbea79ed9511 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ReturnTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Return + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ReturnTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Return + //private Return instance; + + public ReturnTests() + { + // TODO uncomment below to create an instance of Return + //instance = new Return(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Return + /// + [Fact] + public void ReturnInstanceTest() + { + // TODO uncomment below to test "IsType" Return + //Assert.IsType(instance); + } + + /// + /// Test the property 'Lock' + /// + [Fact] + public void LockTest() + { + // TODO unit test for the property 'Lock' + } + + /// + /// Test the property 'Abstract' + /// + [Fact] + public void AbstractTest() + { + // TODO unit test for the property 'Abstract' + } + + /// + /// Test the property 'VarReturn' + /// + [Fact] + public void VarReturnTest() + { + // TODO unit test for the property 'VarReturn' + } + + /// + /// Test the property 'Unsafe' + /// + [Fact] + public void UnsafeTest() + { + // TODO unit test for the property 'Unsafe' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs new file mode 100644 index 000000000000..5f21a874c4f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RolesReportsHashRole + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RolesReportsHashRoleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RolesReportsHashRole + //private RolesReportsHashRole instance; + + public RolesReportsHashRoleTests() + { + // TODO uncomment below to create an instance of RolesReportsHashRole + //instance = new RolesReportsHashRole(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RolesReportsHashRole + /// + [Fact] + public void RolesReportsHashRoleInstanceTest() + { + // TODO uncomment below to test "IsType" RolesReportsHashRole + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs new file mode 100644 index 000000000000..cddb8dc6f0b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RolesReportsHash + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RolesReportsHashTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RolesReportsHash + //private RolesReportsHash instance; + + public RolesReportsHashTests() + { + // TODO uncomment below to create an instance of RolesReportsHash + //instance = new RolesReportsHash(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RolesReportsHash + /// + [Fact] + public void RolesReportsHashInstanceTest() + { + // TODO uncomment below to test "IsType" RolesReportsHash + //Assert.IsType(instance); + } + + /// + /// Test the property 'Role' + /// + [Fact] + public void RoleTest() + { + // TODO unit test for the property 'Role' + } + + /// + /// Test the property 'RoleUuid' + /// + [Fact] + public void RoleUuidTest() + { + // TODO unit test for the property 'RoleUuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs new file mode 100644 index 000000000000..085d3e550a10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ScaleneTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ScaleneTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ScaleneTriangle + //private ScaleneTriangle instance; + + public ScaleneTriangleTests() + { + // TODO uncomment below to create an instance of ScaleneTriangle + //instance = new ScaleneTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ScaleneTriangle + /// + [Fact] + public void ScaleneTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" ScaleneTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs new file mode 100644 index 000000000000..62d6d69ff72d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ShapeInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ShapeInterface + //private ShapeInterface instance; + + public ShapeInterfaceTests() + { + // TODO uncomment below to create an instance of ShapeInterface + //instance = new ShapeInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ShapeInterface + /// + [Fact] + public void ShapeInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" ShapeInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs new file mode 100644 index 000000000000..dc6970b16f15 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ShapeOrNull + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeOrNullTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ShapeOrNull + //private ShapeOrNull instance; + + public ShapeOrNullTests() + { + // TODO uncomment below to create an instance of ShapeOrNull + //instance = new ShapeOrNull(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ShapeOrNull + /// + [Fact] + public void ShapeOrNullInstanceTest() + { + // TODO uncomment below to test "IsType" ShapeOrNull + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeTests.cs new file mode 100644 index 000000000000..dbdf012c5ba4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ShapeTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Shape + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Shape + //private Shape instance; + + public ShapeTests() + { + // TODO uncomment below to create an instance of Shape + //instance = new Shape(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Shape + /// + [Fact] + public void ShapeInstanceTest() + { + // TODO uncomment below to test "IsType" Shape + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs new file mode 100644 index 000000000000..baa6e1e9f6fd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing SimpleQuadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class SimpleQuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for SimpleQuadrilateral + //private SimpleQuadrilateral instance; + + public SimpleQuadrilateralTests() + { + // TODO uncomment below to create an instance of SimpleQuadrilateral + //instance = new SimpleQuadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of SimpleQuadrilateral + /// + [Fact] + public void SimpleQuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" SimpleQuadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs new file mode 100644 index 000000000000..23763d9c3af0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing SpecialModelName + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class SpecialModelNameTests : IDisposable + { + // TODO uncomment below to declare an instance variable for SpecialModelName + //private SpecialModelName instance; + + public SpecialModelNameTests() + { + // TODO uncomment below to create an instance of SpecialModelName + //instance = new SpecialModelName(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of SpecialModelName + /// + [Fact] + public void SpecialModelNameInstanceTest() + { + // TODO uncomment below to test "IsType" SpecialModelName + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarSpecialModelName' + /// + [Fact] + public void VarSpecialModelNameTest() + { + // TODO unit test for the property 'VarSpecialModelName' + } + + /// + /// Test the property 'SpecialPropertyName' + /// + [Fact] + public void SpecialPropertyNameTest() + { + // TODO unit test for the property 'SpecialPropertyName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TagTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TagTests.cs new file mode 100644 index 000000000000..fe7f3d82baba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TagTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Tag + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TagTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Tag + //private Tag instance; + + public TagTests() + { + // TODO uncomment below to create an instance of Tag + //instance = new Tag(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Tag + /// + [Fact] + public void TagInstanceTest() + { + // TODO uncomment below to test "IsType" Tag + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs new file mode 100644 index 000000000000..eca020ce1fae --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestCollectionEndingWithWordListObject + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestCollectionEndingWithWordListObjectTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestCollectionEndingWithWordListObject + //private TestCollectionEndingWithWordListObject instance; + + public TestCollectionEndingWithWordListObjectTests() + { + // TODO uncomment below to create an instance of TestCollectionEndingWithWordListObject + //instance = new TestCollectionEndingWithWordListObject(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestCollectionEndingWithWordListObject + /// + [Fact] + public void TestCollectionEndingWithWordListObjectInstanceTest() + { + // TODO uncomment below to test "IsType" TestCollectionEndingWithWordListObject + //Assert.IsType(instance); + } + + /// + /// Test the property 'TestCollectionEndingWithWordList' + /// + [Fact] + public void TestCollectionEndingWithWordListTest() + { + // TODO unit test for the property 'TestCollectionEndingWithWordList' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs new file mode 100644 index 000000000000..e3c86aefabe3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestCollectionEndingWithWordList + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestCollectionEndingWithWordListTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestCollectionEndingWithWordList + //private TestCollectionEndingWithWordList instance; + + public TestCollectionEndingWithWordListTests() + { + // TODO uncomment below to create an instance of TestCollectionEndingWithWordList + //instance = new TestCollectionEndingWithWordList(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestCollectionEndingWithWordList + /// + [Fact] + public void TestCollectionEndingWithWordListInstanceTest() + { + // TODO uncomment below to test "IsType" TestCollectionEndingWithWordList + //Assert.IsType(instance); + } + + /// + /// Test the property 'Value' + /// + [Fact] + public void ValueTest() + { + // TODO unit test for the property 'Value' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumHeaderStringParameterTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumHeaderStringParameterTests.cs new file mode 100644 index 000000000000..13a2e1eb54fc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumHeaderStringParameterTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestEnumParametersEnumHeaderStringParameter + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestEnumParametersEnumHeaderStringParameterTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestEnumParametersEnumHeaderStringParameter + //private TestEnumParametersEnumHeaderStringParameter instance; + + public TestEnumParametersEnumHeaderStringParameterTests() + { + // TODO uncomment below to create an instance of TestEnumParametersEnumHeaderStringParameter + //instance = new TestEnumParametersEnumHeaderStringParameter(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestEnumParametersEnumHeaderStringParameter + /// + [Fact] + public void TestEnumParametersEnumHeaderStringParameterInstanceTest() + { + // TODO uncomment below to test "IsType" TestEnumParametersEnumHeaderStringParameter + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryDoubleParameterTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryDoubleParameterTests.cs new file mode 100644 index 000000000000..4d7a6d9b6655 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryDoubleParameterTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestEnumParametersEnumQueryDoubleParameter + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestEnumParametersEnumQueryDoubleParameterTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestEnumParametersEnumQueryDoubleParameter + //private TestEnumParametersEnumQueryDoubleParameter instance; + + public TestEnumParametersEnumQueryDoubleParameterTests() + { + // TODO uncomment below to create an instance of TestEnumParametersEnumQueryDoubleParameter + //instance = new TestEnumParametersEnumQueryDoubleParameter(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestEnumParametersEnumQueryDoubleParameter + /// + [Fact] + public void TestEnumParametersEnumQueryDoubleParameterInstanceTest() + { + // TODO uncomment below to test "IsType" TestEnumParametersEnumQueryDoubleParameter + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryIntegerParameterTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryIntegerParameterTests.cs new file mode 100644 index 000000000000..700dbb98ec92 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersEnumQueryIntegerParameterTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestEnumParametersEnumQueryIntegerParameter + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestEnumParametersEnumQueryIntegerParameterTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestEnumParametersEnumQueryIntegerParameter + //private TestEnumParametersEnumQueryIntegerParameter instance; + + public TestEnumParametersEnumQueryIntegerParameterTests() + { + // TODO uncomment below to create an instance of TestEnumParametersEnumQueryIntegerParameter + //instance = new TestEnumParametersEnumQueryIntegerParameter(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestEnumParametersEnumQueryIntegerParameter + /// + [Fact] + public void TestEnumParametersEnumQueryIntegerParameterInstanceTest() + { + // TODO uncomment below to test "IsType" TestEnumParametersEnumQueryIntegerParameter + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringArrayInnerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringArrayInnerTests.cs new file mode 100644 index 000000000000..9dd379868e64 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringArrayInnerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestEnumParametersRequestEnumFormStringArrayInner + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestEnumParametersRequestEnumFormStringArrayInnerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestEnumParametersRequestEnumFormStringArrayInner + //private TestEnumParametersRequestEnumFormStringArrayInner instance; + + public TestEnumParametersRequestEnumFormStringArrayInnerTests() + { + // TODO uncomment below to create an instance of TestEnumParametersRequestEnumFormStringArrayInner + //instance = new TestEnumParametersRequestEnumFormStringArrayInner(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestEnumParametersRequestEnumFormStringArrayInner + /// + [Fact] + public void TestEnumParametersRequestEnumFormStringArrayInnerInstanceTest() + { + // TODO uncomment below to test "IsType" TestEnumParametersRequestEnumFormStringArrayInner + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringTests.cs new file mode 100644 index 000000000000..a99aa2d7d3e8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestEnumParametersRequestEnumFormStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestEnumParametersRequestEnumFormString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestEnumParametersRequestEnumFormStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestEnumParametersRequestEnumFormString + //private TestEnumParametersRequestEnumFormString instance; + + public TestEnumParametersRequestEnumFormStringTests() + { + // TODO uncomment below to create an instance of TestEnumParametersRequestEnumFormString + //instance = new TestEnumParametersRequestEnumFormString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestEnumParametersRequestEnumFormString + /// + [Fact] + public void TestEnumParametersRequestEnumFormStringInstanceTest() + { + // TODO uncomment below to test "IsType" TestEnumParametersRequestEnumFormString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs new file mode 100644 index 000000000000..23e08d8e4e9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestInlineFreeformAdditionalPropertiesRequest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestInlineFreeformAdditionalPropertiesRequestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestInlineFreeformAdditionalPropertiesRequest + //private TestInlineFreeformAdditionalPropertiesRequest instance; + + public TestInlineFreeformAdditionalPropertiesRequestTests() + { + // TODO uncomment below to create an instance of TestInlineFreeformAdditionalPropertiesRequest + //instance = new TestInlineFreeformAdditionalPropertiesRequest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestInlineFreeformAdditionalPropertiesRequest + /// + [Fact] + public void TestInlineFreeformAdditionalPropertiesRequestInstanceTest() + { + // TODO uncomment below to test "IsType" TestInlineFreeformAdditionalPropertiesRequest + //Assert.IsType(instance); + } + + /// + /// Test the property 'SomeProperty' + /// + [Fact] + public void SomePropertyTest() + { + // TODO unit test for the property 'SomeProperty' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs new file mode 100644 index 000000000000..1293a2b212ed --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TriangleInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TriangleInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TriangleInterface + //private TriangleInterface instance; + + public TriangleInterfaceTests() + { + // TODO uncomment below to create an instance of TriangleInterface + //instance = new TriangleInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TriangleInterface + /// + [Fact] + public void TriangleInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" TriangleInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleTests.cs new file mode 100644 index 000000000000..4cb535223483 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TriangleTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Triangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Triangle + //private Triangle instance; + + public TriangleTests() + { + // TODO uncomment below to create an instance of Triangle + //instance = new Triangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Triangle + /// + [Fact] + public void TriangleInstanceTest() + { + // TODO uncomment below to test "IsType" Triangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/UserTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/UserTests.cs new file mode 100644 index 000000000000..6415f8561f1f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/UserTests.cs @@ -0,0 +1,164 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing User + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class UserTests : IDisposable + { + // TODO uncomment below to declare an instance variable for User + //private User instance; + + public UserTests() + { + // TODO uncomment below to create an instance of User + //instance = new User(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of User + /// + [Fact] + public void UserInstanceTest() + { + // TODO uncomment below to test "IsType" User + //Assert.IsType(instance); + } + + /// + /// Test the property 'AnyTypeProp' + /// + [Fact] + public void AnyTypePropTest() + { + // TODO unit test for the property 'AnyTypeProp' + } + + /// + /// Test the property 'AnyTypePropNullable' + /// + [Fact] + public void AnyTypePropNullableTest() + { + // TODO unit test for the property 'AnyTypePropNullable' + } + + /// + /// Test the property 'Email' + /// + [Fact] + public void EmailTest() + { + // TODO unit test for the property 'Email' + } + + /// + /// Test the property 'FirstName' + /// + [Fact] + public void FirstNameTest() + { + // TODO unit test for the property 'FirstName' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'LastName' + /// + [Fact] + public void LastNameTest() + { + // TODO unit test for the property 'LastName' + } + + /// + /// Test the property 'ObjectWithNoDeclaredProps' + /// + [Fact] + public void ObjectWithNoDeclaredPropsTest() + { + // TODO unit test for the property 'ObjectWithNoDeclaredProps' + } + + /// + /// Test the property 'ObjectWithNoDeclaredPropsNullable' + /// + [Fact] + public void ObjectWithNoDeclaredPropsNullableTest() + { + // TODO unit test for the property 'ObjectWithNoDeclaredPropsNullable' + } + + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + + /// + /// Test the property 'Phone' + /// + [Fact] + public void PhoneTest() + { + // TODO unit test for the property 'Phone' + } + + /// + /// Test the property 'UserStatus' + /// + [Fact] + public void UserStatusTest() + { + // TODO unit test for the property 'UserStatus' + } + + /// + /// Test the property 'Username' + /// + [Fact] + public void UsernameTest() + { + // TODO unit test for the property 'Username' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/WhaleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/WhaleTests.cs new file mode 100644 index 000000000000..7d05cc5e59ab --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/WhaleTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Whale + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class WhaleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Whale + //private Whale instance; + + public WhaleTests() + { + // TODO uncomment below to create an instance of Whale + //instance = new Whale(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Whale + /// + [Fact] + public void WhaleInstanceTest() + { + // TODO uncomment below to test "IsType" Whale + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'HasBaleen' + /// + [Fact] + public void HasBaleenTest() + { + // TODO unit test for the property 'HasBaleen' + } + + /// + /// Test the property 'HasTeeth' + /// + [Fact] + public void HasTeethTest() + { + // TODO unit test for the property 'HasTeeth' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTests.cs new file mode 100644 index 000000000000..cd0d1c1c361c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Zebra + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZebraTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Zebra + //private Zebra instance; + + public ZebraTests() + { + // TODO uncomment below to create an instance of Zebra + //instance = new Zebra(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Zebra + /// + [Fact] + public void ZebraInstanceTest() + { + // TODO uncomment below to test "IsType" Zebra + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTypeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTypeTests.cs new file mode 100644 index 000000000000..d257a4a319e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZebraTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZebraType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZebraTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZebraType + //private ZebraType instance; + + public ZebraTypeTests() + { + // TODO uncomment below to create an instance of ZebraType + //instance = new ZebraType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZebraType + /// + [Fact] + public void ZebraTypeInstanceTest() + { + // TODO uncomment below to test "IsType" ZebraType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs new file mode 100644 index 000000000000..b432edb28c23 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZeroBasedEnumClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZeroBasedEnumClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZeroBasedEnumClass + //private ZeroBasedEnumClass instance; + + public ZeroBasedEnumClassTests() + { + // TODO uncomment below to create an instance of ZeroBasedEnumClass + //instance = new ZeroBasedEnumClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZeroBasedEnumClass + /// + [Fact] + public void ZeroBasedEnumClassInstanceTest() + { + // TODO uncomment below to test "IsType" ZeroBasedEnumClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'ZeroBasedEnum' + /// + [Fact] + public void ZeroBasedEnumTest() + { + // TODO unit test for the property 'ZeroBasedEnum' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassZeroBasedEnumTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassZeroBasedEnumTests.cs new file mode 100644 index 000000000000..42fabdfc6a75 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassZeroBasedEnumTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZeroBasedEnumClassZeroBasedEnum + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZeroBasedEnumClassZeroBasedEnumTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZeroBasedEnumClassZeroBasedEnum + //private ZeroBasedEnumClassZeroBasedEnum instance; + + public ZeroBasedEnumClassZeroBasedEnumTests() + { + // TODO uncomment below to create an instance of ZeroBasedEnumClassZeroBasedEnum + //instance = new ZeroBasedEnumClassZeroBasedEnum(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZeroBasedEnumClassZeroBasedEnum + /// + [Fact] + public void ZeroBasedEnumClassZeroBasedEnumInstanceTest() + { + // TODO uncomment below to test "IsType" ZeroBasedEnumClassZeroBasedEnum + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs new file mode 100644 index 000000000000..3689a873c342 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZeroBasedEnum + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZeroBasedEnumTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZeroBasedEnum + //private ZeroBasedEnum instance; + + public ZeroBasedEnumTests() + { + // TODO uncomment below to create an instance of ZeroBasedEnum + //instance = new ZeroBasedEnum(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZeroBasedEnum + /// + [Fact] + public void ZeroBasedEnumInstanceTest() + { + // TODO uncomment below to test "IsType" ZeroBasedEnum + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs new file mode 100644 index 000000000000..c629057faada --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -0,0 +1,402 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IAnotherFakeApi : IApi + { + /// + /// The class containing the events + /// + AnotherFakeApiEvents Events { get; } + + /// + /// To test special tags + /// + /// + /// To test special tags and operation ID starting with number + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test special tags + /// + /// + /// To test special tags and operation ID starting with number + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ICall123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class AnotherFakeApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnCall123TestSpecialTags; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCall123TestSpecialTags; + + internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse) + { + OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) + { + OnErrorCall123TestSpecialTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class AnotherFakeApi : IAnotherFakeApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public AnotherFakeApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public AnotherFakeApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = anotherFakeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatCall123TestSpecialTags(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCall123TestSpecialTags(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorCall123TestSpecialTags(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCall123TestSpecialTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test special tags To test special tags and operation ID starting with number + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await Call123TestSpecialTagsAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test special tags To test special tags and operation ID starting with number + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCall123TestSpecialTags(modelClient); + + FormatCall123TestSpecialTags(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/another-fake/dummy"; + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnCall123TestSpecialTags(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorCall123TestSpecialTags(e); + throw; + } + } + + /// + /// The + /// + public partial class Call123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, ICall123TestSpecialTagsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public Call123TestSpecialTagsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..d58e33914732 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,1352 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task FooGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Hello + /// + /// + /// Hello + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task HelloAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Hello + /// + /// + /// Hello + /// + /// Cancellation Token to cancel the request. + /// <> + Task HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task TestAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IFooGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IDefault + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IGetCountryApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IHelloApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IRolesReportGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnFooGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFooGet; + + internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse) + { + OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFooGet(Exception exception) + { + OnErrorFooGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetCountry; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetCountry; + + internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse) + { + OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetCountry(Exception exception) + { + OnErrorGetCountry?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnHello; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorHello; + + internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse) + { + OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorHello(Exception exception) + { + OnErrorHello?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnRolesReportGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorRolesReportGet; + + internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse) + { + OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorRolesReportGet(Exception exception) + { + OnErrorRolesReportGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTest; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTest; + + internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse) + { + OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTest(Exception exception) + { + OnErrorTest?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + /// + /// Processes the server response + /// + /// + private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorFooGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFooGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FooGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task FooGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/foo"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFooGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnFooGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFooGet(e); + throw; + } + } + + /// + /// The + /// + public partial class FooGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFooGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FooGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + /// + /// Deserializes the response if the response is 0 Default + /// + /// + public Org.OpenAPITools.Model.FooGetDefaultResponse Default() + { + // This logic may be modified with the AsModel.mustache template + return IsDefault + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 0 Default and the deserialized response is not null + /// + /// + /// + public bool TryDefault(out Org.OpenAPITools.Model.FooGetDefaultResponse result) + { + result = null; + + try + { + result = Default(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetCountry(ref string country); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateGetCountry(string country) + { + if (country == null) + throw new ArgumentNullException(nameof(country)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country) + { + bool suppressDefaultLog = false; + AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) + { + bool suppressDefaultLog = false; + OnErrorGetCountry(ref suppressDefaultLog, exception, pathFormat, path, country); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetCountry(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string country); + + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetCountryAsync(country, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateGetCountry(country); + + FormatGetCountry(ref country); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/country"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); + + Events.ExecuteOnGetCountry(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); + Events.ExecuteOnErrorGetCountry(e); + throw; + } + } + + /// + /// The + /// + public partial class GetCountryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetCountryApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetCountryApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterHello(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorHello(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorHello(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Hello Hello + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await HelloAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Hello Hello + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task HelloAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/hello"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + + AfterHelloDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnHello(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorHello(e); + throw; + } + } + + /// + /// The + /// + public partial class HelloApiResponse : Org.OpenAPITools.Client.ApiResponse, IHelloApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public HelloApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorRolesReportGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorRolesReportGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorRolesReportGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await RolesReportGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/roles/report"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + + AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnRolesReportGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorRolesReportGetDefaultImplementation(e, "/roles/report", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRolesReportGet(e); + throw; + } + } + + /// + /// The + /// + public partial class RolesReportGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRolesReportGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public RolesReportGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterTest(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorTestDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorTest(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTest(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/test"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnTest(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestDefaultImplementation(e, "/test", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorTest(e); + throw; + } + } + + /// + /// The + /// + public partial class TestApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs new file mode 100644 index 000000000000..0be949dd5922 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -0,0 +1,5181 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IFakeApi : IApi + { + /// + /// The class containing the events + /// + FakeApiEvents Events { get; } + + /// + /// Health check endpoint + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task FakeHealthGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Health check endpoint + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterBooleanSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterBooleanSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterCompositeSerializeAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterCompositeSerializeOrDefaultAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterNumberSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterNumberSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterStringSerializeAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterStringSerializeOrDefaultAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Array of Enums + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetArrayOfEnumsAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Array of Enums + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestAdditionalPropertiesReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestAdditionalPropertiesReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithFileSchemaOrDefaultAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithQueryParamsAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithQueryParamsOrDefaultAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Thrown when fails to make API call + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Form parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional) + /// Query parameter enum test (string) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestEnumParametersAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Form parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional) + /// Query parameter enum test (string) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestEnumParametersOrDefaultAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint to test group parameters (optional) + /// + /// + /// Fake endpoint to test group parameters (optional) + /// + /// Thrown when fails to make API call + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestGroupParametersAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint to test group parameters (optional) + /// + /// + /// Fake endpoint to test group parameters (optional) + /// + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestGroupParametersOrDefaultAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineAdditionalPropertiesOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline free-form additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineFreeformAdditionalPropertiesAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline free-form additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineFreeformAdditionalPropertiesOrDefaultAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test json serialization of form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test json serialization of form data + /// + /// + /// + /// + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + Task TestJsonFormDataOrDefaultAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// To test the collection format in query parameters + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// To test the collection format in query parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestQueryParameterCollectionFormatOrDefaultAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced string map + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestStringMapReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced string map + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestStringMapReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IFakeHealthGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterBooleanSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterCompositeSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterNumberSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterStringSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestAdditionalPropertiesReferenceApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestBodyWithFileSchemaApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestBodyWithQueryParamsApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestClientModelApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestEndpointParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface ITestEnumParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface ITestGroupParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface ITestInlineAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestInlineFreeformAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestJsonFormDataApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestQueryParameterCollectionFormatApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestStringMapReferenceApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class FakeApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeHealthGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeHealthGet; + + internal void ExecuteOnFakeHealthGet(FakeApi.FakeHealthGetApiResponse apiResponse) + { + OnFakeHealthGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeHealthGet(Exception exception) + { + OnErrorFakeHealthGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterBooleanSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterBooleanSerialize; + + internal void ExecuteOnFakeOuterBooleanSerialize(FakeApi.FakeOuterBooleanSerializeApiResponse apiResponse) + { + OnFakeOuterBooleanSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterBooleanSerialize(Exception exception) + { + OnErrorFakeOuterBooleanSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterCompositeSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterCompositeSerialize; + + internal void ExecuteOnFakeOuterCompositeSerialize(FakeApi.FakeOuterCompositeSerializeApiResponse apiResponse) + { + OnFakeOuterCompositeSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterCompositeSerialize(Exception exception) + { + OnErrorFakeOuterCompositeSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterNumberSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterNumberSerialize; + + internal void ExecuteOnFakeOuterNumberSerialize(FakeApi.FakeOuterNumberSerializeApiResponse apiResponse) + { + OnFakeOuterNumberSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterNumberSerialize(Exception exception) + { + OnErrorFakeOuterNumberSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterStringSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterStringSerialize; + + internal void ExecuteOnFakeOuterStringSerialize(FakeApi.FakeOuterStringSerializeApiResponse apiResponse) + { + OnFakeOuterStringSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterStringSerialize(Exception exception) + { + OnErrorFakeOuterStringSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetArrayOfEnums; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetArrayOfEnums; + + internal void ExecuteOnGetArrayOfEnums(FakeApi.GetArrayOfEnumsApiResponse apiResponse) + { + OnGetArrayOfEnums?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) + { + OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestAdditionalPropertiesReference; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestAdditionalPropertiesReference; + + internal void ExecuteOnTestAdditionalPropertiesReference(FakeApi.TestAdditionalPropertiesReferenceApiResponse apiResponse) + { + OnTestAdditionalPropertiesReference?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestAdditionalPropertiesReference(Exception exception) + { + OnErrorTestAdditionalPropertiesReference?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestBodyWithFileSchema; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithFileSchema; + + internal void ExecuteOnTestBodyWithFileSchema(FakeApi.TestBodyWithFileSchemaApiResponse apiResponse) + { + OnTestBodyWithFileSchema?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestBodyWithFileSchema(Exception exception) + { + OnErrorTestBodyWithFileSchema?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestBodyWithQueryParams; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithQueryParams; + + internal void ExecuteOnTestBodyWithQueryParams(FakeApi.TestBodyWithQueryParamsApiResponse apiResponse) + { + OnTestBodyWithQueryParams?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestBodyWithQueryParams(Exception exception) + { + OnErrorTestBodyWithQueryParams?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestClientModel; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClientModel; + + internal void ExecuteOnTestClientModel(FakeApi.TestClientModelApiResponse apiResponse) + { + OnTestClientModel?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestClientModel(Exception exception) + { + OnErrorTestClientModel?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestEndpointParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEndpointParameters; + + internal void ExecuteOnTestEndpointParameters(FakeApi.TestEndpointParametersApiResponse apiResponse) + { + OnTestEndpointParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestEndpointParameters(Exception exception) + { + OnErrorTestEndpointParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestEnumParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEnumParameters; + + internal void ExecuteOnTestEnumParameters(FakeApi.TestEnumParametersApiResponse apiResponse) + { + OnTestEnumParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestEnumParameters(Exception exception) + { + OnErrorTestEnumParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestGroupParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestGroupParameters; + + internal void ExecuteOnTestGroupParameters(FakeApi.TestGroupParametersApiResponse apiResponse) + { + OnTestGroupParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestGroupParameters(Exception exception) + { + OnErrorTestGroupParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestInlineAdditionalProperties; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineAdditionalProperties; + + internal void ExecuteOnTestInlineAdditionalProperties(FakeApi.TestInlineAdditionalPropertiesApiResponse apiResponse) + { + OnTestInlineAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestInlineAdditionalProperties(Exception exception) + { + OnErrorTestInlineAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestInlineFreeformAdditionalProperties; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineFreeformAdditionalProperties; + + internal void ExecuteOnTestInlineFreeformAdditionalProperties(FakeApi.TestInlineFreeformAdditionalPropertiesApiResponse apiResponse) + { + OnTestInlineFreeformAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestInlineFreeformAdditionalProperties(Exception exception) + { + OnErrorTestInlineFreeformAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestJsonFormData; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestJsonFormData; + + internal void ExecuteOnTestJsonFormData(FakeApi.TestJsonFormDataApiResponse apiResponse) + { + OnTestJsonFormData?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestJsonFormData(Exception exception) + { + OnErrorTestJsonFormData?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestQueryParameterCollectionFormat; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestQueryParameterCollectionFormat; + + internal void ExecuteOnTestQueryParameterCollectionFormat(FakeApi.TestQueryParameterCollectionFormatApiResponse apiResponse) + { + OnTestQueryParameterCollectionFormat?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception exception) + { + OnErrorTestQueryParameterCollectionFormat?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestStringMapReference; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestStringMapReference; + + internal void ExecuteOnTestStringMapReference(FakeApi.TestStringMapReferenceApiResponse apiResponse) + { + OnTestStringMapReference?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestStringMapReference(Exception exception) + { + OnErrorTestStringMapReference?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class FakeApi : IFakeApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public FakeApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = fakeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + /// + /// Processes the server response + /// + /// + private void AfterFakeHealthGetDefaultImplementation(IFakeHealthGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterFakeHealthGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterFakeHealthGet(ref bool suppressDefaultLog, IFakeHealthGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorFakeHealthGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeHealthGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Health check endpoint + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeHealthGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Health check endpoint + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeHealthGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/health"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnFakeHealthGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFakeHealthGet(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeHealthGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeHealthGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeHealthGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.HealthCheckResult Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.HealthCheckResult result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterBooleanSerialize(ref Option body); + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterBooleanSerializeDefaultImplementation(IFakeOuterBooleanSerializeApiResponse apiResponseLocalVar, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterBooleanSerialize(ref suppressDefaultLog, apiResponseLocalVar, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterBooleanSerialize(ref bool suppressDefaultLog, IFakeOuterBooleanSerializeApiResponse apiResponseLocalVar, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterBooleanSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterBooleanSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); + + /// + /// Test serialization of outer boolean types + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterBooleanSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterBooleanSerializeAsync(body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterBooleanSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatFakeOuterBooleanSerialize(ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/boolean"; + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); + + Events.ExecuteOnFakeOuterBooleanSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterBooleanSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterBooleanSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterBooleanSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterBooleanSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public bool? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out bool? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterCompositeSerialize(Option outerComposite); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFakeOuterCompositeSerialize(Option outerComposite) + { + if (outerComposite.IsSet && outerComposite.Value == null) + throw new ArgumentNullException(nameof(outerComposite)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterCompositeSerializeDefaultImplementation(IFakeOuterCompositeSerializeApiResponse apiResponseLocalVar, Option outerComposite) + { + bool suppressDefaultLog = false; + AfterFakeOuterCompositeSerialize(ref suppressDefaultLog, apiResponseLocalVar, outerComposite); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterCompositeSerialize(ref bool suppressDefaultLog, IFakeOuterCompositeSerializeApiResponse apiResponseLocalVar, Option outerComposite); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option outerComposite) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterCompositeSerialize(ref suppressDefaultLog, exception, pathFormat, path, outerComposite); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterCompositeSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option outerComposite); + + /// + /// Test serialization of object with outer number type + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterCompositeSerializeOrDefaultAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterCompositeSerializeAsync(outerComposite, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterCompositeSerializeAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFakeOuterCompositeSerialize(outerComposite); + + FormatFakeOuterCompositeSerialize(outerComposite); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/composite"; + + if (outerComposite.IsSet) + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); + + Events.ExecuteOnFakeOuterCompositeSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + Events.ExecuteOnErrorFakeOuterCompositeSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterCompositeSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterCompositeSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterCompositeSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.OuterComposite Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.OuterComposite result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterNumberSerialize(ref Option body); + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterNumberSerializeDefaultImplementation(IFakeOuterNumberSerializeApiResponse apiResponseLocalVar, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterNumberSerialize(ref suppressDefaultLog, apiResponseLocalVar, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterNumberSerialize(ref bool suppressDefaultLog, IFakeOuterNumberSerializeApiResponse apiResponseLocalVar, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterNumberSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterNumberSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); + + /// + /// Test serialization of outer number types + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterNumberSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterNumberSerializeAsync(body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterNumberSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatFakeOuterNumberSerialize(ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/number"; + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); + + Events.ExecuteOnFakeOuterNumberSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterNumberSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterNumberSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterNumberSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterNumberSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public decimal? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out decimal? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterStringSerialize(ref Guid requiredStringUuid, ref Option body); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFakeOuterStringSerialize(Option body) + { + if (body.IsSet && body.Value == null) + throw new ArgumentNullException(nameof(body)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterFakeOuterStringSerializeDefaultImplementation(IFakeOuterStringSerializeApiResponse apiResponseLocalVar, Guid requiredStringUuid, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterStringSerialize(ref suppressDefaultLog, apiResponseLocalVar, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterFakeOuterStringSerialize(ref bool suppressDefaultLog, IFakeOuterStringSerializeApiResponse apiResponseLocalVar, Guid requiredStringUuid, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterStringSerialize(ref suppressDefaultLog, exception, pathFormat, path, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterStringSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); + + /// + /// Test serialization of outer string types + /// + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterStringSerializeOrDefaultAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterStringSerializeAsync(requiredStringUuid, body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterStringSerializeAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFakeOuterStringSerialize(body); + + FormatFakeOuterStringSerialize(ref requiredStringUuid, ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/string"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["required_string_uuid"] = ClientUtils.ParameterToString(requiredStringUuid); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); + + Events.ExecuteOnFakeOuterStringSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + Events.ExecuteOnErrorFakeOuterStringSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterStringSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterStringSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterStringSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public string Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out string result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetArrayOfEnumsDefaultImplementation(IGetArrayOfEnumsApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetArrayOfEnums(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetArrayOfEnums(ref bool suppressDefaultLog, IGetArrayOfEnumsApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetArrayOfEnums(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetArrayOfEnums(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Array of Enums + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetArrayOfEnumsAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Array of Enums + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetArrayOfEnumsAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/array-of-enums"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetArrayOfEnums(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetArrayOfEnums(e); + throw; + } + } + + /// + /// The + /// + public partial class GetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetArrayOfEnumsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetArrayOfEnumsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestAdditionalPropertiesReference(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestAdditionalPropertiesReferenceDefaultImplementation(ITestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestAdditionalPropertiesReference(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestAdditionalPropertiesReference(ref bool suppressDefaultLog, ITestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestAdditionalPropertiesReferenceDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestAdditionalPropertiesReference(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestAdditionalPropertiesReference(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test referenced additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAdditionalPropertiesReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestAdditionalPropertiesReferenceAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test referenced additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAdditionalPropertiesReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestAdditionalPropertiesReference(requestBody); + + FormatTestAdditionalPropertiesReference(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/additionalProperties-reference"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestAdditionalPropertiesReference(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestAdditionalPropertiesReferenceDefaultImplementation(e, "/fake/additionalProperties-reference", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestAdditionalPropertiesReference(e); + throw; + } + } + + /// + /// The + /// + public partial class TestAdditionalPropertiesReferenceApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestAdditionalPropertiesReferenceApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestAdditionalPropertiesReferenceApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) + { + if (fileSchemaTestClass == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestBodyWithFileSchemaDefaultImplementation(ITestBodyWithFileSchemaApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) + { + bool suppressDefaultLog = false; + AfterTestBodyWithFileSchema(ref suppressDefaultLog, apiResponseLocalVar, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestBodyWithFileSchema(ref bool suppressDefaultLog, ITestBodyWithFileSchemaApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) + { + bool suppressDefaultLog = false; + OnErrorTestBodyWithFileSchema(ref suppressDefaultLog, exception, pathFormat, path, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithFileSchema(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithFileSchemaOrDefaultAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestBodyWithFileSchemaAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestBodyWithFileSchema(fileSchemaTestClass); + + FormatTestBodyWithFileSchema(fileSchemaTestClass); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/body-with-file-schema"; + + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); + + Events.ExecuteOnTestBodyWithFileSchema(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + Events.ExecuteOnErrorTestBodyWithFileSchema(e); + throw; + } + } + + /// + /// The + /// + public partial class TestBodyWithFileSchemaApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestBodyWithFileSchemaApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestBodyWithFileSchemaApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestBodyWithQueryParams(User user, ref string query); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateTestBodyWithQueryParams(User user, string query) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + + if (query == null) + throw new ArgumentNullException(nameof(query)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterTestBodyWithQueryParamsDefaultImplementation(ITestBodyWithQueryParamsApiResponse apiResponseLocalVar, User user, string query) + { + bool suppressDefaultLog = false; + AfterTestBodyWithQueryParams(ref suppressDefaultLog, apiResponseLocalVar, user, query); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterTestBodyWithQueryParams(ref bool suppressDefaultLog, ITestBodyWithQueryParamsApiResponse apiResponseLocalVar, User user, string query); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) + { + bool suppressDefaultLog = false; + OnErrorTestBodyWithQueryParams(ref suppressDefaultLog, exception, pathFormat, path, user, query); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithQueryParams(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string query); + + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithQueryParamsOrDefaultAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestBodyWithQueryParamsAsync(user, query, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithQueryParamsAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestBodyWithQueryParams(user, query); + + FormatTestBodyWithQueryParams(user, ref query); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/body-with-query-params"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["query"] = ClientUtils.ParameterToString(query); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, user, query); + + Events.ExecuteOnTestBodyWithQueryParams(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + Events.ExecuteOnErrorTestBodyWithQueryParams(e); + throw; + } + } + + /// + /// The + /// + public partial class TestBodyWithQueryParamsApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestBodyWithQueryParamsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestBodyWithQueryParamsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestClientModel(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestClientModel(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestClientModelDefaultImplementation(ITestClientModelApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterTestClientModel(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestClientModel(ref bool suppressDefaultLog, ITestClientModelApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorTestClientModel(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestClientModel(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test \"client\" model To test \"client\" model + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestClientModelAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test \"client\" model To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestClientModel(modelClient); + + FormatTestClientModel(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnTestClientModel(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClientModel(e); + throw; + } + } + + /// + /// The + /// + public partial class TestClientModelApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClientModelApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestClientModelApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestEndpointParameters(ref byte[] varByte, ref decimal number, ref double varDouble, ref string patternWithoutDelimiter, ref Option date, ref Option binary, ref Option varFloat, ref Option integer, ref Option int32, ref Option int64, ref Option varString, ref Option password, ref Option callback, ref Option dateTime); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + /// + /// + /// + private void ValidateTestEndpointParameters(byte[] varByte, string patternWithoutDelimiter, Option binary, Option varString, Option password, Option callback) + { + if (varByte == null) + throw new ArgumentNullException(nameof(varByte)); + + if (patternWithoutDelimiter == null) + throw new ArgumentNullException(nameof(patternWithoutDelimiter)); + + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary)); + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString)); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password)); + + if (callback.IsSet && callback.Value == null) + throw new ArgumentNullException(nameof(callback)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) + { + bool suppressDefaultLog = false; + AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) + { + bool suppressDefaultLog = false; + OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestEndpointParametersAsync(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestEndpointParameters(varByte, patternWithoutDelimiter, binary, varString, password, callback); + + FormatTestEndpointParameters(ref varByte, ref number, ref varDouble, ref patternWithoutDelimiter, ref date, ref binary, ref varFloat, ref integer, ref int32, ref int64, ref varString, ref password, ref callback, ref dateTime); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); + + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); + + if (date.IsSet) + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + + if (binary.IsSet) + multipartContentLocalVar.Add(new StreamContent(binary.Value)); + + if (varFloat.IsSet) + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + + if (integer.IsSet) + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + + if (int32.IsSet) + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + + if (int64.IsSet) + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + + if (varString.IsSet) + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + + if (password.IsSet) + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + + if (callback.IsSet) + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + + if (dateTime.IsSet) + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + BasicToken basicTokenLocalVar1 = (BasicToken) await BasicTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(basicTokenLocalVar1); + + basicTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + + Events.ExecuteOnTestEndpointParameters(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + Events.ExecuteOnErrorTestEndpointParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestEndpointParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestEndpointParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestEndpointParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestEnumParameters(Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, ref Option enumHeaderString, ref Option enumQueryString, ref Option enumQueryDouble, ref Option enumQueryInteger, ref Option enumFormString); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + private void ValidateTestEnumParameters(Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray) + { + if (enumHeaderStringArray.IsSet && enumHeaderStringArray.Value == null) + throw new ArgumentNullException(nameof(enumHeaderStringArray)); + + if (enumQueryStringArray.IsSet && enumQueryStringArray.Value == null) + throw new ArgumentNullException(nameof(enumQueryStringArray)); + + if (enumFormStringArray.IsSet && enumFormStringArray.Value == null) + throw new ArgumentNullException(nameof(enumFormStringArray)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestEnumParametersDefaultImplementation(ITestEnumParametersApiResponse apiResponseLocalVar, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumQueryDouble, Option enumQueryInteger, Option enumFormString) + { + bool suppressDefaultLog = false; + AfterTestEnumParameters(ref suppressDefaultLog, apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEnumParameters(ref bool suppressDefaultLog, ITestEnumParametersApiResponse apiResponseLocalVar, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumQueryDouble, Option enumQueryInteger, Option enumFormString); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumQueryDouble, Option enumQueryInteger, Option enumFormString) + { + bool suppressDefaultLog = false; + OnErrorTestEnumParameters(ref suppressDefaultLog, exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEnumParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumQueryDouble, Option enumQueryInteger, Option enumFormString); + + /// + /// To test enum parameters To test enum parameters + /// + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Form parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional) + /// Query parameter enum test (string) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEnumParametersOrDefaultAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestEnumParametersAsync(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test enum parameters To test enum parameters + /// + /// Thrown when fails to make API call + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Form parameter enum test (string array) (optional) + /// Header parameter enum test (string) (optional) + /// Query parameter enum test (string) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEnumParametersAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestEnumParameters(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray); + + FormatTestEnumParameters(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, ref enumHeaderString, ref enumQueryString, ref enumQueryDouble, ref enumQueryInteger, ref enumFormString); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + if (enumQueryStringArray.IsSet) + // here too + parseQueryStringLocalVar["enum_query_string_array"] = ClientUtils.ParameterToString(enumQueryStringArray.Value); + + if (enumQueryString.IsSet) + // here too + parseQueryStringLocalVar["enum_query_string"] = ClientUtils.ParameterToString(enumQueryString.Value); + + if (enumQueryDouble.IsSet) + // here too + parseQueryStringLocalVar["enum_query_double"] = ClientUtils.ParameterToString(enumQueryDouble.Value); + + if (enumQueryInteger.IsSet) + // here too + parseQueryStringLocalVar["enum_query_integer"] = ClientUtils.ParameterToString(enumQueryInteger.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + if (enumHeaderStringArray.IsSet) + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + + if (enumHeaderString.IsSet) + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormStringArray.IsSet) + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + + if (enumFormString.IsSet) + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + + Events.ExecuteOnTestEnumParameters(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumQueryDouble, enumQueryInteger, enumFormString); + Events.ExecuteOnErrorTestEnumParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestEnumParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestEnumParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestEnumParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestGroupParameters(ref bool requiredBooleanGroup, ref int requiredStringGroup, ref long requiredInt64Group, ref Option booleanGroup, ref Option stringGroup, ref Option int64Group); + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestGroupParametersDefaultImplementation(ITestGroupParametersApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) + { + bool suppressDefaultLog = false; + AfterTestGroupParameters(ref suppressDefaultLog, apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestGroupParameters(ref bool suppressDefaultLog, ITestGroupParametersApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) + { + bool suppressDefaultLog = false; + OnErrorTestGroupParameters(ref suppressDefaultLog, exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestGroupParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + + /// + /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) + /// + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestGroupParametersOrDefaultAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestGroupParametersAsync(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) + /// + /// Thrown when fails to make API call + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestGroupParametersAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatTestGroupParameters(ref requiredBooleanGroup, ref requiredStringGroup, ref requiredInt64Group, ref booleanGroup, ref stringGroup, ref int64Group); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["required_string_group"] = ClientUtils.ParameterToString(requiredStringGroup); + parseQueryStringLocalVar["required_int64_group"] = ClientUtils.ParameterToString(requiredInt64Group); + + if (stringGroup.IsSet) + // here too + parseQueryStringLocalVar["string_group"] = ClientUtils.ParameterToString(stringGroup.Value); + + if (int64Group.IsSet) + // here too + parseQueryStringLocalVar["int64_group"] = ClientUtils.ParameterToString(int64Group.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + + if (booleanGroup.IsSet) + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + BearerToken bearerTokenLocalVar1 = (BearerToken) await BearerTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(bearerTokenLocalVar1); + + bearerTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + + Events.ExecuteOnTestGroupParameters(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + Events.ExecuteOnErrorTestGroupParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestGroupParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestGroupParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestGroupParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestInlineAdditionalProperties(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestInlineAdditionalProperties(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestInlineAdditionalPropertiesDefaultImplementation(ITestInlineAdditionalPropertiesApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestInlineAdditionalProperties(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestInlineAdditionalProperties(ref bool suppressDefaultLog, ITestInlineAdditionalPropertiesApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestInlineAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestInlineAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test inline additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineAdditionalPropertiesOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestInlineAdditionalPropertiesAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test inline additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestInlineAdditionalProperties(requestBody); + + FormatTestInlineAdditionalProperties(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/inline-additionalProperties"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestInlineAdditionalProperties(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestInlineAdditionalProperties(e); + throw; + } + } + + /// + /// The + /// + public partial class TestInlineAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestInlineAdditionalPropertiesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestInlineAdditionalPropertiesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + if (testInlineFreeformAdditionalPropertiesRequest == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(ITestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + bool suppressDefaultLog = false; + AfterTestInlineFreeformAdditionalProperties(ref suppressDefaultLog, apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestInlineFreeformAdditionalProperties(ref bool suppressDefaultLog, ITestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestInlineFreeformAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + bool suppressDefaultLog = false; + OnErrorTestInlineFreeformAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, testInlineFreeformAdditionalPropertiesRequest); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestInlineFreeformAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// test inline free-form additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineFreeformAdditionalPropertiesOrDefaultAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestInlineFreeformAdditionalPropertiesAsync(testInlineFreeformAdditionalPropertiesRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test inline free-form additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineFreeformAdditionalPropertiesAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + + FormatTestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/inline-freeform-additionalProperties"; + + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); + + Events.ExecuteOnTestInlineFreeformAdditionalProperties(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestInlineFreeformAdditionalPropertiesDefaultImplementation(e, "/fake/inline-freeform-additionalProperties", uriBuilderLocalVar.Path, testInlineFreeformAdditionalPropertiesRequest); + Events.ExecuteOnErrorTestInlineFreeformAdditionalProperties(e); + throw; + } + } + + /// + /// The + /// + public partial class TestInlineFreeformAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestInlineFreeformAdditionalPropertiesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestInlineFreeformAdditionalPropertiesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestJsonFormData(ref string param, ref string param2); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateTestJsonFormData(string param, string param2) + { + if (param == null) + throw new ArgumentNullException(nameof(param)); + + if (param2 == null) + throw new ArgumentNullException(nameof(param2)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterTestJsonFormDataDefaultImplementation(ITestJsonFormDataApiResponse apiResponseLocalVar, string param, string param2) + { + bool suppressDefaultLog = false; + AfterTestJsonFormData(ref suppressDefaultLog, apiResponseLocalVar, param, param2); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterTestJsonFormData(ref bool suppressDefaultLog, ITestJsonFormDataApiResponse apiResponseLocalVar, string param, string param2); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) + { + bool suppressDefaultLog = false; + OnErrorTestJsonFormData(ref suppressDefaultLog, exception, pathFormat, path, param, param2); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestJsonFormData(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string param, string param2); + + /// + /// test json serialization of form data + /// + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + public async Task TestJsonFormDataOrDefaultAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestJsonFormDataAsync(param, param2, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test json serialization of form data + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + public async Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestJsonFormData(param, param2); + + FormatTestJsonFormData(ref param, ref param2); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/jsonFormData"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); + + Events.ExecuteOnTestJsonFormData(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + Events.ExecuteOnErrorTestJsonFormData(e); + throw; + } + } + + /// + /// The + /// + public partial class TestJsonFormDataApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestJsonFormDataApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestJsonFormDataApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, ref string requiredNotNullable, ref string requiredNullable, ref Option notRequiredNotNullable, ref Option notRequiredNullable); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void ValidateTestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, Option notRequiredNotNullable) + { + if (pipe == null) + throw new ArgumentNullException(nameof(pipe)); + + if (ioutil == null) + throw new ArgumentNullException(nameof(ioutil)); + + if (http == null) + throw new ArgumentNullException(nameof(http)); + + if (url == null) + throw new ArgumentNullException(nameof(url)); + + if (context == null) + throw new ArgumentNullException(nameof(context)); + + if (requiredNotNullable == null) + throw new ArgumentNullException(nameof(requiredNotNullable)); + + if (notRequiredNotNullable.IsSet && notRequiredNotNullable.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotNullable)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestQueryParameterCollectionFormatDefaultImplementation(ITestQueryParameterCollectionFormatApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) + { + bool suppressDefaultLog = false; + AfterTestQueryParameterCollectionFormat(ref suppressDefaultLog, apiResponseLocalVar, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, ITestQueryParameterCollectionFormatApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) + { + bool suppressDefaultLog = false; + OnErrorTestQueryParameterCollectionFormat(ref suppressDefaultLog, exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + + /// + /// To test the collection format in query parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestQueryParameterCollectionFormatOrDefaultAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestQueryParameterCollectionFormatAsync(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test the collection format in query parameters + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, requiredNotNullable, notRequiredNotNullable); + + FormatTestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, ref requiredNotNullable, ref requiredNullable, ref notRequiredNotNullable, ref notRequiredNullable); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/test-query-parameters"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["pipe"] = ClientUtils.ParameterToString(pipe); + parseQueryStringLocalVar["ioutil"] = ClientUtils.ParameterToString(ioutil); + parseQueryStringLocalVar["http"] = ClientUtils.ParameterToString(http); + parseQueryStringLocalVar["url"] = ClientUtils.ParameterToString(url); + parseQueryStringLocalVar["context"] = ClientUtils.ParameterToString(context); + parseQueryStringLocalVar["requiredNotNullable"] = ClientUtils.ParameterToString(requiredNotNullable); + parseQueryStringLocalVar["requiredNullable"] = ClientUtils.ParameterToString(requiredNullable); + + if (notRequiredNotNullable.IsSet) + // here too + parseQueryStringLocalVar["notRequiredNotNullable"] = ClientUtils.ParameterToString(notRequiredNotNullable.Value); + + if (notRequiredNullable.IsSet) + // here too + parseQueryStringLocalVar["notRequiredNullable"] = ClientUtils.ParameterToString(notRequiredNullable.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + + Events.ExecuteOnTestQueryParameterCollectionFormat(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + Events.ExecuteOnErrorTestQueryParameterCollectionFormat(e); + throw; + } + } + + /// + /// The + /// + public partial class TestQueryParameterCollectionFormatApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestQueryParameterCollectionFormatApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestQueryParameterCollectionFormatApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestStringMapReference(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestStringMapReference(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestStringMapReferenceDefaultImplementation(ITestStringMapReferenceApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestStringMapReference(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestStringMapReference(ref bool suppressDefaultLog, ITestStringMapReferenceApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestStringMapReferenceDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestStringMapReference(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestStringMapReference(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test referenced string map + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestStringMapReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestStringMapReferenceAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test referenced string map + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestStringMapReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestStringMapReference(requestBody); + + FormatTestStringMapReference(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/stringMap-reference"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestStringMapReference(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestStringMapReferenceDefaultImplementation(e, "/fake/stringMap-reference", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestStringMapReference(e); + throw; + } + } + + /// + /// The + /// + public partial class TestStringMapReferenceApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestStringMapReferenceApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestStringMapReferenceApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs new file mode 100644 index 000000000000..1d5bd38c5279 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -0,0 +1,415 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IFakeClassnameTags123Api : IApi + { + /// + /// The class containing the events + /// + FakeClassnameTags123ApiEvents Events { get; } + + /// + /// To test class name in snake case + /// + /// + /// To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test class name in snake case + /// + /// + /// To test class name in snake case + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ITestClassnameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class FakeClassnameTags123ApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnTestClassname; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClassname; + + internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse) + { + OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestClassname(Exception exception) + { + OnErrorTestClassname?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public FakeClassnameTags123ApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeClassnameTags123Api(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = fakeClassnameTags123ApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatTestClassname(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestClassname(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorTestClassname(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestClassname(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test class name in snake case To test class name in snake case + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestClassnameAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test class name in snake case To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestClassname(modelClient); + + FormatTestClassname(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake_classname_test"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + + apiKeyTokenLocalVar1.UseInQuery(httpRequestMessageLocalVar, uriBuilderLocalVar, parseQueryStringLocalVar); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnTestClassname(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClassname(e); + throw; + } + } + + /// + /// The + /// + public partial class TestClassnameApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClassnameApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestClassnameApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs new file mode 100644 index 000000000000..d97995fd5ff2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/PetApi.cs @@ -0,0 +1,2784 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IPetApi : IApi + { + /// + /// The class containing the events + /// + PetApiEvents Events { get; } + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task AddPetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task AddPetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task DeletePetAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task DeletePetOrDefaultAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter (deprecated) + /// Cancellation Token to cancel the request. + /// <> + Task FindPetsByStatusAsync(List status, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter (deprecated) + /// Cancellation Token to cancel the request. + /// <> + Task FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + [Obsolete] + Task FindPetsByTagsAsync(List tags, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + [Obsolete] + Task FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + Task GetPetByIdAsync(long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetWithFormAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetWithFormOrDefaultAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileOrDefaultAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image (required) + /// + /// + /// + /// + /// Thrown when fails to make API call + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileWithRequiredFileAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image (required) + /// + /// + /// + /// + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileWithRequiredFileOrDefaultAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IAddPetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IDeletePetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IFindPetsByStatusApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IFindPetsByTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IGetPetByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IUpdatePetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IUpdatePetWithFormApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IUploadFileApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class PetApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnAddPet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorAddPet; + + internal void ExecuteOnAddPet(PetApi.AddPetApiResponse apiResponse) + { + OnAddPet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorAddPet(Exception exception) + { + OnErrorAddPet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnDeletePet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeletePet; + + internal void ExecuteOnDeletePet(PetApi.DeletePetApiResponse apiResponse) + { + OnDeletePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeletePet(Exception exception) + { + OnErrorDeletePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFindPetsByStatus; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByStatus; + + internal void ExecuteOnFindPetsByStatus(PetApi.FindPetsByStatusApiResponse apiResponse) + { + OnFindPetsByStatus?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFindPetsByStatus(Exception exception) + { + OnErrorFindPetsByStatus?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFindPetsByTags; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByTags; + + internal void ExecuteOnFindPetsByTags(PetApi.FindPetsByTagsApiResponse apiResponse) + { + OnFindPetsByTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFindPetsByTags(Exception exception) + { + OnErrorFindPetsByTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetPetById; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetPetById; + + internal void ExecuteOnGetPetById(PetApi.GetPetByIdApiResponse apiResponse) + { + OnGetPetById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetPetById(Exception exception) + { + OnErrorGetPetById?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdatePet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePet; + + internal void ExecuteOnUpdatePet(PetApi.UpdatePetApiResponse apiResponse) + { + OnUpdatePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdatePet(Exception exception) + { + OnErrorUpdatePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdatePetWithForm; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePetWithForm; + + internal void ExecuteOnUpdatePetWithForm(PetApi.UpdatePetWithFormApiResponse apiResponse) + { + OnUpdatePetWithForm?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdatePetWithForm(Exception exception) + { + OnErrorUpdatePetWithForm?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFile; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFile; + + internal void ExecuteOnUploadFile(PetApi.UploadFileApiResponse apiResponse) + { + OnUploadFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFile(Exception exception) + { + OnErrorUploadFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFileWithRequiredFile; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFileWithRequiredFile; + + internal void ExecuteOnUploadFileWithRequiredFile(PetApi.UploadFileWithRequiredFileApiResponse apiResponse) + { + OnUploadFileWithRequiredFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) + { + OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class PetApi : IPetApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public PetApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public PetApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = petApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatAddPet(Pet pet); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateAddPet(Pet pet) + { + if (pet == null) + throw new ArgumentNullException(nameof(pet)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterAddPetDefaultImplementation(IAddPetApiResponse apiResponseLocalVar, Pet pet) + { + bool suppressDefaultLog = false; + AfterAddPet(ref suppressDefaultLog, apiResponseLocalVar, pet); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterAddPet(ref bool suppressDefaultLog, IAddPetApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) + { + bool suppressDefaultLog = false; + OnErrorAddPet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorAddPet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task AddPetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await AddPetAsync(pet, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Add a new pet to the store + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task AddPetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateAddPet(pet); + + FormatAddPet(pet); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + Uri urlLocalVar = httpRequestMessageLocalVar.RequestUri = new Uri("http://petstore.swagger.io/v2"); + uriBuilderLocalVar.Host = urlLocalVar.Authority; + uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; + uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; + + httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + + AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); + + Events.ExecuteOnAddPet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorAddPet(e); + throw; + } + } + + /// + /// The + /// + public partial class AddPetApiResponse : Org.OpenAPITools.Client.ApiResponse, IAddPetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public AddPetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatDeletePet(ref long petId, ref Option apiKey); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeletePet(Option apiKey) + { + if (apiKey.IsSet && apiKey.Value == null) + throw new ArgumentNullException(nameof(apiKey)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterDeletePetDefaultImplementation(IDeletePetApiResponse apiResponseLocalVar, long petId, Option apiKey) + { + bool suppressDefaultLog = false; + AfterDeletePet(ref suppressDefaultLog, apiResponseLocalVar, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterDeletePet(ref bool suppressDefaultLog, IDeletePetApiResponse apiResponseLocalVar, long petId, Option apiKey); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option apiKey) + { + bool suppressDefaultLog = false; + OnErrorDeletePet(ref suppressDefaultLog, exception, pathFormat, path, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorDeletePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option apiKey); + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task DeletePetOrDefaultAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeletePetAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Deletes a pet + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task DeletePetAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeletePet(apiKey); + + FormatDeletePet(ref petId, ref apiKey); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + if (apiKey.IsSet) + httpRequestMessageLocalVar.Headers.Add("api_key", ClientUtils.ParameterToString(apiKey.Value)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); + + Events.ExecuteOnDeletePet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + Events.ExecuteOnErrorDeletePet(e); + throw; + } + } + + /// + /// The + /// + public partial class DeletePetApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeletePetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeletePetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFindPetsByStatus(List status); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFindPetsByStatus(List status) + { + if (status == null) + throw new ArgumentNullException(nameof(status)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFindPetsByStatusDefaultImplementation(IFindPetsByStatusApiResponse apiResponseLocalVar, List status) + { + bool suppressDefaultLog = false; + AfterFindPetsByStatus(ref suppressDefaultLog, apiResponseLocalVar, status); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFindPetsByStatus(ref bool suppressDefaultLog, IFindPetsByStatusApiResponse apiResponseLocalVar, List status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) + { + bool suppressDefaultLog = false; + OnErrorFindPetsByStatus(ref suppressDefaultLog, exception, pathFormat, path, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByStatus(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List status); + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FindPetsByStatusAsync(status, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByStatusAsync(List status, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFindPetsByStatus(status); + + FormatFindPetsByStatus(status); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/findByStatus"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["status"] = ClientUtils.ParameterToString(status); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); + + Events.ExecuteOnFindPetsByStatus(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + Events.ExecuteOnErrorFindPetsByStatus(e); + throw; + } + } + + /// + /// The + /// + public partial class FindPetsByStatusApiResponse : Org.OpenAPITools.Client.ApiResponse, IFindPetsByStatusApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FindPetsByStatusApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFindPetsByTags(List tags); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFindPetsByTags(List tags) + { + if (tags == null) + throw new ArgumentNullException(nameof(tags)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFindPetsByTagsDefaultImplementation(IFindPetsByTagsApiResponse apiResponseLocalVar, List tags) + { + bool suppressDefaultLog = false; + AfterFindPetsByTags(ref suppressDefaultLog, apiResponseLocalVar, tags); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFindPetsByTags(ref bool suppressDefaultLog, IFindPetsByTagsApiResponse apiResponseLocalVar, List tags); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) + { + bool suppressDefaultLog = false; + OnErrorFindPetsByTags(ref suppressDefaultLog, exception, pathFormat, path, tags); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List tags); + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FindPetsByTagsAsync(tags, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByTagsAsync(List tags, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFindPetsByTags(tags); + + FormatFindPetsByTags(tags); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/findByTags"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["tags"] = ClientUtils.ParameterToString(tags); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); + + Events.ExecuteOnFindPetsByTags(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + Events.ExecuteOnErrorFindPetsByTags(e); + throw; + } + } + + /// + /// The + /// + public partial class FindPetsByTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, IFindPetsByTagsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FindPetsByTagsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetPetById(ref long petId); + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetPetByIdDefaultImplementation(IGetPetByIdApiResponse apiResponseLocalVar, long petId) + { + bool suppressDefaultLog = false; + AfterGetPetById(ref suppressDefaultLog, apiResponseLocalVar, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetPetById(ref bool suppressDefaultLog, IGetPetByIdApiResponse apiResponseLocalVar, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) + { + bool suppressDefaultLog = false; + OnErrorGetPetById(ref suppressDefaultLog, exception, pathFormat, path, petId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetPetById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId); + + /// + /// Find pet by ID Returns a single pet + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + public async Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetPetByIdAsync(petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Find pet by ID Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + public async Task GetPetByIdAsync(long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatGetPetById(ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + apiKeyTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar); + + ApiKeyToken apiKeyTokenLocalVar2 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar2); + + apiKeyTokenLocalVar2.UseInQuery(httpRequestMessageLocalVar, uriBuilderLocalVar, parseQueryStringLocalVar); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); + + Events.ExecuteOnGetPetById(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + Events.ExecuteOnErrorGetPetById(e); + throw; + } + } + + /// + /// The + /// + public partial class GetPetByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetPetByIdApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetPetByIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Pet Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Pet result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdatePet(Pet pet); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUpdatePet(Pet pet) + { + if (pet == null) + throw new ArgumentNullException(nameof(pet)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterUpdatePetDefaultImplementation(IUpdatePetApiResponse apiResponseLocalVar, Pet pet) + { + bool suppressDefaultLog = false; + AfterUpdatePet(ref suppressDefaultLog, apiResponseLocalVar, pet); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterUpdatePet(ref bool suppressDefaultLog, IUpdatePetApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) + { + bool suppressDefaultLog = false; + OnErrorUpdatePet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdatePetAsync(pet, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Update an existing pet + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdatePet(pet); + + FormatUpdatePet(pet); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + Uri urlLocalVar = httpRequestMessageLocalVar.RequestUri = new Uri("http://petstore.swagger.io/v2"); + uriBuilderLocalVar.Host = urlLocalVar.Authority; + uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; + uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; + + httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); + + Events.ExecuteOnUpdatePet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorUpdatePet(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdatePetApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdatePetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdatePetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdatePetWithForm(ref long petId, ref Option name, ref Option status); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUpdatePetWithForm(Option name, Option status) + { + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name)); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUpdatePetWithFormDefaultImplementation(IUpdatePetWithFormApiResponse apiResponseLocalVar, long petId, Option name, Option status) + { + bool suppressDefaultLog = false; + AfterUpdatePetWithForm(ref suppressDefaultLog, apiResponseLocalVar, petId, name, status); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUpdatePetWithForm(ref bool suppressDefaultLog, IUpdatePetWithFormApiResponse apiResponseLocalVar, long petId, Option name, Option status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option name, Option status) + { + bool suppressDefaultLog = false; + OnErrorUpdatePetWithForm(ref suppressDefaultLog, exception, pathFormat, path, petId, name, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePetWithForm(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option name, Option status); + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetWithFormOrDefaultAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdatePetWithFormAsync(petId, name, status, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Updates a pet in the store with form data + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetWithFormAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdatePetWithForm(name, status); + + FormatUpdatePetWithForm(ref petId, ref name, ref status); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + + if (status.IsSet) + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); + + Events.ExecuteOnUpdatePetWithForm(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + Events.ExecuteOnErrorUpdatePetWithForm(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdatePetWithFormApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdatePetWithFormApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdatePetWithFormApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUploadFile(ref long petId, ref Option file, ref Option additionalMetadata); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUploadFile(Option file, Option additionalMetadata) + { + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file)); + + if (additionalMetadata.IsSet && additionalMetadata.Value == null) + throw new ArgumentNullException(nameof(additionalMetadata)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option file, Option additionalMetadata) + { + bool suppressDefaultLog = false; + AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option file, Option additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata) + { + bool suppressDefaultLog = false; + OnErrorUploadFile(ref suppressDefaultLog, exception, pathFormat, path, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); + + /// + /// uploads an image + /// + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileOrDefaultAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFileAsync(petId, file, additionalMetadata, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an image + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFile(file, additionalMetadata); + + FormatUploadFile(ref petId, ref file, ref additionalMetadata); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}/uploadImage"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (file.IsSet) + multipartContentLocalVar.Add(new StreamContent(file.Value)); + + if (additionalMetadata.IsSet) + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata); + + Events.ExecuteOnUploadFile(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + Events.ExecuteOnErrorUploadFile(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFileApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFileApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFileApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUploadFileWithRequiredFile(ref System.IO.Stream requiredFile, ref long petId, ref Option additionalMetadata); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + { + if (requiredFile == null) + throw new ArgumentNullException(nameof(requiredFile)); + + if (additionalMetadata.IsSet && additionalMetadata.Value == null) + throw new ArgumentNullException(nameof(additionalMetadata)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, Option additionalMetadata) + { + bool suppressDefaultLog = false; + AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata) + { + bool suppressDefaultLog = false; + OnErrorUploadFileWithRequiredFile(ref suppressDefaultLog, exception, pathFormat, path, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + + /// + /// uploads an image (required) + /// + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileWithRequiredFileOrDefaultAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an image (required) + /// + /// Thrown when fails to make API call + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileWithRequiredFileAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFileWithRequiredFile(requiredFile, additionalMetadata); + + FormatUploadFileWithRequiredFile(ref requiredFile, ref petId, ref additionalMetadata); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/{petId}/uploadImageWithRequiredFile"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + + if (additionalMetadata.IsSet) + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata); + + Events.ExecuteOnUploadFileWithRequiredFile(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + Events.ExecuteOnErrorUploadFileWithRequiredFile(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFileWithRequiredFileApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFileWithRequiredFileApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs new file mode 100644 index 000000000000..4e9980c869e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/StoreApi.cs @@ -0,0 +1,1197 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IStoreApi : IApi + { + /// + /// The class containing the events + /// + StoreApiEvents Events { get; } + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + Task DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Cancellation Token to cancel the request. + /// <> + Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + Task PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IDeleteOrderApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IGetInventoryApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetOrderByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IPlaceOrderApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class StoreApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnDeleteOrder; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteOrder; + + internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse) + { + OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeleteOrder(Exception exception) + { + OnErrorDeleteOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetInventory; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetInventory; + + internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse) + { + OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetInventory(Exception exception) + { + OnErrorGetInventory?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetOrderById; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetOrderById; + + internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse) + { + OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetOrderById(Exception exception) + { + OnErrorGetOrderById?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnPlaceOrder; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorPlaceOrder; + + internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse) + { + OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorPlaceOrder(Exception exception) + { + OnErrorPlaceOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class StoreApi : IStoreApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public StoreApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public StoreApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = storeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatDeleteOrder(ref string orderId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeleteOrder(string orderId) + { + if (orderId == null) + throw new ArgumentNullException(nameof(orderId)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId) + { + bool suppressDefaultLog = false; + AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) + { + bool suppressDefaultLog = false; + OnErrorDeleteOrder(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeleteOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string orderId); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeleteOrderAsync(orderId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeleteOrder(orderId); + + FormatDeleteOrder(ref orderId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order/{order_id}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); + + Events.ExecuteOnDeleteOrder(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorDeleteOrder(e); + throw; + } + } + + /// + /// The + /// + public partial class DeleteOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteOrderApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeleteOrderApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetInventory(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetInventory(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetInventoryAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/inventory"; + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + apiKeyTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetInventoryDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetInventory(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetInventory(e); + throw; + } + } + + /// + /// The + /// + public partial class GetInventoryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetInventoryApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetInventoryApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Dictionary Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Dictionary result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetOrderById(ref long orderId); + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId) + { + bool suppressDefaultLog = false; + AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) + { + bool suppressDefaultLog = false; + OnErrorGetOrderById(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetOrderById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long orderId); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + public async Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetOrderByIdAsync(orderId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Cancellation Token to cancel the request. + /// <> + public async Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatGetOrderById(ref orderId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order/{order_id}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); + + Events.ExecuteOnGetOrderById(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorGetOrderById(e); + throw; + } + } + + /// + /// The + /// + public partial class GetOrderByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetOrderByIdApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetOrderByIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Order Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Order result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatPlaceOrder(Order order); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidatePlaceOrder(Order order) + { + if (order == null) + throw new ArgumentNullException(nameof(order)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order) + { + bool suppressDefaultLog = false; + AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) + { + bool suppressDefaultLog = false; + OnErrorPlaceOrder(ref suppressDefaultLog, exception, pathFormat, path, order); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorPlaceOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Order order); + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + public async Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await PlaceOrderAsync(order, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Place an order for a pet + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + public async Task PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidatePlaceOrder(order); + + FormatPlaceOrder(order); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order"; + + httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + + AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); + + Events.ExecuteOnPlaceOrder(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); + Events.ExecuteOnErrorPlaceOrder(e); + throw; + } + } + + /// + /// The + /// + public partial class PlaceOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IPlaceOrderApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public PlaceOrderApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Order Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Order result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs new file mode 100644 index 000000000000..721984089ad9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/UserApi.cs @@ -0,0 +1,2223 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IUserApi : IApi + { + /// + /// The class containing the events + /// + UserApiEvents Events { get; } + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUserAsync(User user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUserOrDefaultAsync(User user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithArrayInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithListInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteUserAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteUserOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Get user by user name + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + Task GetUserByNameAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + Task LoginUserAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task LogoutUserAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task LogoutUserOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task UpdateUserAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task UpdateUserOrDefaultAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ICreateUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface ICreateUsersWithArrayInputApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface ICreateUsersWithListInputApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IDeleteUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IGetUserByNameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk, ICustomHttpStatusCode599 + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + + /// + /// Returns true if the response is 598 CustomHttpStatusCode598 + /// + /// + bool IsCustomHttpStatusCode598 { get; } + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 + /// + /// + bool IsCustomHttpStatusCode599 { get; } + } + + /// + /// The + /// + public interface ILoginUserApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface ILogoutUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IUpdateUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class UserApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUser; + + internal void ExecuteOnCreateUser(UserApi.CreateUserApiResponse apiResponse) + { + OnCreateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUser(Exception exception) + { + OnErrorCreateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUsersWithArrayInput; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithArrayInput; + + internal void ExecuteOnCreateUsersWithArrayInput(UserApi.CreateUsersWithArrayInputApiResponse apiResponse) + { + OnCreateUsersWithArrayInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUsersWithArrayInput(Exception exception) + { + OnErrorCreateUsersWithArrayInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUsersWithListInput; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithListInput; + + internal void ExecuteOnCreateUsersWithListInput(UserApi.CreateUsersWithListInputApiResponse apiResponse) + { + OnCreateUsersWithListInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUsersWithListInput(Exception exception) + { + OnErrorCreateUsersWithListInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnDeleteUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteUser; + + internal void ExecuteOnDeleteUser(UserApi.DeleteUserApiResponse apiResponse) + { + OnDeleteUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeleteUser(Exception exception) + { + OnErrorDeleteUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetUserByName; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetUserByName; + + internal void ExecuteOnGetUserByName(UserApi.GetUserByNameApiResponse apiResponse) + { + OnGetUserByName?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetUserByName(Exception exception) + { + OnErrorGetUserByName?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnLoginUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLoginUser; + + internal void ExecuteOnLoginUser(UserApi.LoginUserApiResponse apiResponse) + { + OnLoginUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorLoginUser(Exception exception) + { + OnErrorLoginUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnLogoutUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLogoutUser; + + internal void ExecuteOnLogoutUser(UserApi.LogoutUserApiResponse apiResponse) + { + OnLogoutUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorLogoutUser(Exception exception) + { + OnErrorLogoutUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdateUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdateUser; + + internal void ExecuteOnUpdateUser(UserApi.UpdateUserApiResponse apiResponse) + { + OnUpdateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdateUser(Exception exception) + { + OnErrorUpdateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class UserApi : IUserApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public UserApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public UserApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = userApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatCreateUser(User user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUser(User user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUserDefaultImplementation(ICreateUserApiResponse apiResponseLocalVar, User user) + { + bool suppressDefaultLog = false; + AfterCreateUser(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUser(ref bool suppressDefaultLog, ICreateUserApiResponse apiResponseLocalVar, User user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) + { + bool suppressDefaultLog = false; + OnErrorCreateUser(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user); + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUserOrDefaultAsync(User user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUserAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUserAsync(User user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUser(user); + + FormatCreateUser(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUser(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatCreateUsersWithArrayInput(List user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUsersWithArrayInput(List user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUsersWithArrayInputDefaultImplementation(ICreateUsersWithArrayInputApiResponse apiResponseLocalVar, List user) + { + bool suppressDefaultLog = false; + AfterCreateUsersWithArrayInput(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUsersWithArrayInput(ref bool suppressDefaultLog, ICreateUsersWithArrayInputApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) + { + bool suppressDefaultLog = false; + OnErrorCreateUsersWithArrayInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithArrayInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithArrayInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUsersWithArrayInputAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUsersWithArrayInput(user); + + FormatCreateUsersWithArrayInput(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/createWithArray"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUsersWithArrayInput(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithArrayInput(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUsersWithArrayInputApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUsersWithArrayInputApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUsersWithArrayInputApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatCreateUsersWithListInput(List user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUsersWithListInput(List user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUsersWithListInputDefaultImplementation(ICreateUsersWithListInputApiResponse apiResponseLocalVar, List user) + { + bool suppressDefaultLog = false; + AfterCreateUsersWithListInput(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUsersWithListInput(ref bool suppressDefaultLog, ICreateUsersWithListInputApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) + { + bool suppressDefaultLog = false; + OnErrorCreateUsersWithListInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithListInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithListInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUsersWithListInputAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUsersWithListInput(user); + + FormatCreateUsersWithListInput(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/createWithList"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUsersWithListInput(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithListInput(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUsersWithListInputApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUsersWithListInputApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUsersWithListInputApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatDeleteUser(ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeleteUser(string username) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterDeleteUserDefaultImplementation(IDeleteUserApiResponse apiResponseLocalVar, string username) + { + bool suppressDefaultLog = false; + AfterDeleteUser(ref suppressDefaultLog, apiResponseLocalVar, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterDeleteUser(ref bool suppressDefaultLog, IDeleteUserApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) + { + bool suppressDefaultLog = false; + OnErrorDeleteUser(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeleteUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteUserOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeleteUserAsync(username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteUserAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeleteUser(username); + + FormatDeleteUser(ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); + + Events.ExecuteOnDeleteUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorDeleteUser(e); + throw; + } + } + + /// + /// The + /// + public partial class DeleteUserApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeleteUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetUserByName(ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateGetUserByName(string username) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetUserByNameDefaultImplementation(IGetUserByNameApiResponse apiResponseLocalVar, string username) + { + bool suppressDefaultLog = false; + AfterGetUserByName(ref suppressDefaultLog, apiResponseLocalVar, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetUserByName(ref bool suppressDefaultLog, IGetUserByNameApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) + { + bool suppressDefaultLog = false; + OnErrorGetUserByName(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetUserByName(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + public async Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetUserByNameAsync(username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Get user by user name + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + public async Task GetUserByNameAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateGetUserByName(username); + + FormatGetUserByName(ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); + + Events.ExecuteOnGetUserByName(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorGetUserByName(e); + throw; + } + } + + /// + /// The + /// + public partial class GetUserByNameApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetUserByNameApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetUserByNameApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.User Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.User result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + /// + /// Returns true if the response is 598 CustomHttpStatusCode598 + /// + /// + public bool IsCustomHttpStatusCode598 => 598 == (int)StatusCode; + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 + /// + /// + public bool IsCustomHttpStatusCode599 => 599 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 599 CustomHttpStatusCode599 + /// + /// + public Org.OpenAPITools.Model.User CustomHttpStatusCode599() + { + // This logic may be modified with the AsModel.mustache template + return IsCustomHttpStatusCode599 + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 and the deserialized response is not null + /// + /// + /// + public bool TryCustomHttpStatusCode599(out Org.OpenAPITools.Model.User result) + { + result = null; + + try + { + result = CustomHttpStatusCode599(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)599); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatLoginUser(ref string username, ref string password); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateLoginUser(string username, string password) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + + if (password == null) + throw new ArgumentNullException(nameof(password)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterLoginUserDefaultImplementation(ILoginUserApiResponse apiResponseLocalVar, string username, string password) + { + bool suppressDefaultLog = false; + AfterLoginUser(ref suppressDefaultLog, apiResponseLocalVar, username, password); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterLoginUser(ref bool suppressDefaultLog, ILoginUserApiResponse apiResponseLocalVar, string username, string password); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) + { + bool suppressDefaultLog = false; + OnErrorLoginUser(ref suppressDefaultLog, exception, pathFormat, path, username, password); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorLoginUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username, string password); + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + public async Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await LoginUserAsync(username, password, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Logs user into the system + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + public async Task LoginUserAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateLoginUser(username, password); + + FormatLoginUser(ref username, ref password); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/login"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["username"] = ClientUtils.ParameterToString(username); + parseQueryStringLocalVar["password"] = ClientUtils.ParameterToString(password); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + + AfterLoginUserDefaultImplementation(apiResponseLocalVar, username, password); + + Events.ExecuteOnLoginUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); + Events.ExecuteOnErrorLoginUser(e); + throw; + } + } + + /// + /// The + /// + public partial class LoginUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ILoginUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public LoginUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public string Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out string result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterLogoutUserDefaultImplementation(ILogoutUserApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterLogoutUser(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterLogoutUser(ref bool suppressDefaultLog, ILogoutUserApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorLogoutUser(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorLogoutUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Logs out current logged in user session + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task LogoutUserOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await LogoutUserAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Logs out current logged in user session + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task LogoutUserAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/logout"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + + AfterLogoutUserDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnLogoutUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorLogoutUser(e); + throw; + } + } + + /// + /// The + /// + public partial class LogoutUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ILogoutUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public LogoutUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdateUser(User user, ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUpdateUser(User user, string username) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUpdateUserDefaultImplementation(IUpdateUserApiResponse apiResponseLocalVar, User user, string username) + { + bool suppressDefaultLog = false; + AfterUpdateUser(ref suppressDefaultLog, apiResponseLocalVar, user, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUpdateUser(ref bool suppressDefaultLog, IUpdateUserApiResponse apiResponseLocalVar, User user, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) + { + bool suppressDefaultLog = false; + OnErrorUpdateUser(ref suppressDefaultLog, exception, pathFormat, path, user, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string username); + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdateUserOrDefaultAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdateUserAsync(user, username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdateUserAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdateUser(user, username); + + FormatUpdateUser(user, ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); + + Events.ExecuteOnUpdateUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + Events.ExecuteOnErrorUpdateUser(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdateUserApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdateUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdateUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..fdd11dd19c9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiKeyToken.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiKeyToken.cs new file mode 100644 index 000000000000..b8bdf9964ffb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiKeyToken.cs @@ -0,0 +1,52 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from an apiKey. + /// + public class ApiKeyToken : TokenBase + { + private string _raw; + + /// + /// The header that this token will be used with. + /// + public ClientUtils.ApiKeyHeader Header { get; } + + /// + /// Constructs an ApiKeyToken object. + /// + /// + /// + /// + /// + public ApiKeyToken(string value, ClientUtils.ApiKeyHeader header, string prefix = "Bearer ", TimeSpan? timeout = null) : base(timeout) + { + Header = header; + _raw = $"{ prefix }{ value }"; + } + + /// + /// Places the token in the header. + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request) + { + request.Headers.Add(ClientUtils.ApiKeyHeaderToString(Header), _raw); + } + + /// + /// Places the token in the query. + /// + /// + /// + /// + public virtual void UseInQuery(System.Net.Http.HttpRequestMessage request, UriBuilder uriBuilder, System.Collections.Specialized.NameValueCollection parseQueryString) + { + parseQueryString[ClientUtils.ApiKeyHeaderToString(Header)] = Uri.EscapeDataString(_raw).ToString(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..63c4e7c4bc3a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,210 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface ICustomHttpStatusCode599 : IApiResponse + { + /// + /// Deserializes the response if the response is CustomHttpStatusCode599 + /// + /// + TType CustomHttpStatusCode599(); + + /// + /// Returns true if the response is CustomHttpStatusCode599 and the deserialized response is not null + /// + /// + /// + bool TryCustomHttpStatusCode599(out TType result); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } + + /// + /// An interface for responses of type + /// + /// + public interface IDefault : IApiResponse + { + /// + /// Deserializes the response if the response is Default + /// + /// + TType Default(); + + /// + /// Returns true if the response is Default and the deserialized response is not null + /// + /// + /// + bool TryDefault(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BasicToken.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BasicToken.cs new file mode 100644 index 000000000000..c58c0563231f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BasicToken.cs @@ -0,0 +1,42 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from a username and password. + /// + public class BasicToken : TokenBase + { + private string _username; + + private string _password; + + /// + /// Constructs a BasicToken object. + /// + /// + /// + /// + public BasicToken(string username, string password, TimeSpan? timeout = null) : base(timeout) + { + _username = username; + + _password = password; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Org.OpenAPITools.Client.ClientUtils.Base64Encode(_username + ":" + _password)); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BearerToken.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BearerToken.cs new file mode 100644 index 000000000000..df5c2310bacd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/BearerToken.cs @@ -0,0 +1,37 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from a token from a bearer token. + /// + public class BearerToken : TokenBase + { + private string _raw; + + /// + /// Constructs a BearerToken object. + /// + /// + /// + public BearerToken(string value, TimeSpan? timeout = null) : base(timeout) + { + _raw = value; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _raw); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..efff79097e03 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,423 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using KellermanSoftware.CompareNetObjects; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static constructor to initialise compareLogic. + /// + static ClientUtils() + { + ComparisonConfig comparisonConfig = new ComparisonConfig(); + comparisonConfig.UseHashCodeIdentifier = true; + compareLogic = new CompareLogic(comparisonConfig); + } + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// An enum of headers + /// + public enum ApiKeyHeader + { + /// + /// The api_key header + /// + Api_key, + /// + /// The api_key_query header + /// + Api_key_query + } + + /// + /// Converte an ApiKeyHeader to a string + /// + /// + /// + /// + public static string ApiKeyHeaderToString(ApiKeyHeader value) + { + switch(value) + { + case ApiKeyHeader.Api_key: + return "api_key"; + case ApiKeyHeader.Api_key_query: + return "api_key_query"; + default: + throw new System.ComponentModel.InvalidEnumArgumentException(nameof(value), (int)value, typeof(ApiKeyHeader)); + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ChildCatAllOfPetType childCatAllOfPetType) + return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); + if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) + return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); + if (obj is EnumArraysJustSymbol enumArraysJustSymbol) + return EnumArraysJustSymbolValueConverter.ToJsonValue(enumArraysJustSymbol); + if (obj is EnumClass enumClass) + return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTestEnumInteger enumTestEnumInteger) + return EnumTestEnumIntegerValueConverter.ToJsonValue(enumTestEnumInteger).ToString(); + if (obj is EnumTestEnumIntegerOnly enumTestEnumIntegerOnly) + return EnumTestEnumIntegerOnlyValueConverter.ToJsonValue(enumTestEnumIntegerOnly).ToString(); + if (obj is EnumTestEnumString enumTestEnumString) + return EnumTestEnumStringValueConverter.ToJsonValue(enumTestEnumString); + if (obj is FindPetsByStatusStatusParameterInner findPetsByStatusStatusParameterInner) + return FindPetsByStatusStatusParameterInnerValueConverter.ToJsonValue(findPetsByStatusStatusParameterInner); + if (obj is MapTestMapOfEnumStringValue mapTestMapOfEnumStringValue) + return MapTestMapOfEnumStringValueValueConverter.ToJsonValue(mapTestMapOfEnumStringValue); + if (obj is OrderStatus orderStatus) + return OrderStatusValueConverter.ToJsonValue(orderStatus); + if (obj is OuterEnum outerEnum) + return OuterEnumValueConverter.ToJsonValue(outerEnum); + if (obj is OuterEnumDefaultValue outerEnumDefaultValue) + return OuterEnumDefaultValueValueConverter.ToJsonValue(outerEnumDefaultValue); + if (obj is OuterEnumInteger outerEnumInteger) + return OuterEnumIntegerValueConverter.ToJsonValue(outerEnumInteger).ToString(); + if (obj is OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue) + return OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(outerEnumIntegerDefaultValue).ToString(); + if (obj is OuterEnumTest outerEnumTest) + return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); + if (obj is PetStatus petStatus) + return PetStatusValueConverter.ToJsonValue(petStatus); + if (obj is RequiredClassRequiredNotnullableEnumInteger requiredClassRequiredNotnullableEnumInteger) + return RequiredClassRequiredNotnullableEnumIntegerValueConverter.ToJsonValue(requiredClassRequiredNotnullableEnumInteger).ToString(); + if (obj is RequiredClassRequiredNotnullableEnumIntegerOnly requiredClassRequiredNotnullableEnumIntegerOnly) + return RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnly).ToString(); + if (obj is RequiredClassRequiredNotnullableEnumString requiredClassRequiredNotnullableEnumString) + return RequiredClassRequiredNotnullableEnumStringValueConverter.ToJsonValue(requiredClassRequiredNotnullableEnumString); + if (obj is RequiredClassRequiredNullableEnumInteger requiredClassRequiredNullableEnumInteger) + return RequiredClassRequiredNullableEnumIntegerValueConverter.ToJsonValue(requiredClassRequiredNullableEnumInteger).ToString(); + if (obj is RequiredClassRequiredNullableEnumIntegerOnly requiredClassRequiredNullableEnumIntegerOnly) + return RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClassRequiredNullableEnumIntegerOnly).ToString(); + if (obj is RequiredClassRequiredNullableEnumString requiredClassRequiredNullableEnumString) + return RequiredClassRequiredNullableEnumStringValueConverter.ToJsonValue(requiredClassRequiredNullableEnumString); + if (obj is TestEnumParametersEnumHeaderStringParameter testEnumParametersEnumHeaderStringParameter) + return TestEnumParametersEnumHeaderStringParameterValueConverter.ToJsonValue(testEnumParametersEnumHeaderStringParameter); + if (obj is TestEnumParametersEnumQueryDoubleParameter testEnumParametersEnumQueryDoubleParameter) + return TestEnumParametersEnumQueryDoubleParameterValueConverter.ToJsonValue(testEnumParametersEnumQueryDoubleParameter).ToString(); + if (obj is TestEnumParametersEnumQueryIntegerParameter testEnumParametersEnumQueryIntegerParameter) + return TestEnumParametersEnumQueryIntegerParameterValueConverter.ToJsonValue(testEnumParametersEnumQueryIntegerParameter).ToString(); + if (obj is TestEnumParametersRequestEnumFormString testEnumParametersRequestEnumFormString) + return TestEnumParametersRequestEnumFormStringValueConverter.ToJsonValue(testEnumParametersRequestEnumFormString); + if (obj is TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner) + return TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.ToJsonValue(testEnumParametersRequestEnumFormStringArrayInner); + if (obj is ZebraType zebraType) + return ZebraTypeValueConverter.ToJsonValue(zebraType); + if (obj is ZeroBasedEnum zeroBasedEnum) + return ZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnum); + if (obj is ZeroBasedEnumClassZeroBasedEnum zeroBasedEnumClassZeroBasedEnum) + return ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClassZeroBasedEnum); + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://petstore.swagger.io:80/v2"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = "/v2"; + + /// + /// The host of the API + /// + public const string HOST = "petstore.swagger.io"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..973f9e9d4e80 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..b491c61f07fa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..750d414c6e25 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,290 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new ActivityJsonConverter()); + _jsonOptions.Converters.Add(new ActivityOutputElementRepresentationJsonConverter()); + _jsonOptions.Converters.Add(new AdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new AnimalJsonConverter()); + _jsonOptions.Converters.Add(new ApiResponseJsonConverter()); + _jsonOptions.Converters.Add(new AppleJsonConverter()); + _jsonOptions.Converters.Add(new AppleReqJsonConverter()); + _jsonOptions.Converters.Add(new ArrayOfArrayOfNumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ArrayOfNumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ArrayTestJsonConverter()); + _jsonOptions.Converters.Add(new BananaJsonConverter()); + _jsonOptions.Converters.Add(new BananaReqJsonConverter()); + _jsonOptions.Converters.Add(new BasquePigJsonConverter()); + _jsonOptions.Converters.Add(new CapitalizationJsonConverter()); + _jsonOptions.Converters.Add(new CatJsonConverter()); + _jsonOptions.Converters.Add(new CategoryJsonConverter()); + _jsonOptions.Converters.Add(new ChildCatJsonConverter()); + _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeJsonConverter()); + _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeNullableJsonConverter()); + _jsonOptions.Converters.Add(new ClassModelJsonConverter()); + _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new DanishPigJsonConverter()); + _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); + _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); + _jsonOptions.Converters.Add(new DogJsonConverter()); + _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysJustSymbolJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysJustSymbolNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumClassJsonConverter()); + _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumIntegerJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumIntegerNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumIntegerOnlyJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumIntegerOnlyNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumStringJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new EquilateralTriangleJsonConverter()); + _jsonOptions.Converters.Add(new FileJsonConverter()); + _jsonOptions.Converters.Add(new FileSchemaTestClassJsonConverter()); + _jsonOptions.Converters.Add(new FindPetsByStatusStatusParameterInnerJsonConverter()); + _jsonOptions.Converters.Add(new FindPetsByStatusStatusParameterInnerNullableJsonConverter()); + _jsonOptions.Converters.Add(new FooJsonConverter()); + _jsonOptions.Converters.Add(new FooGetDefaultResponseJsonConverter()); + _jsonOptions.Converters.Add(new FormatTestJsonConverter()); + _jsonOptions.Converters.Add(new FruitJsonConverter()); + _jsonOptions.Converters.Add(new FruitReqJsonConverter()); + _jsonOptions.Converters.Add(new GmFruitJsonConverter()); + _jsonOptions.Converters.Add(new GrandparentAnimalJsonConverter()); + _jsonOptions.Converters.Add(new HasOnlyReadOnlyJsonConverter()); + _jsonOptions.Converters.Add(new HealthCheckResultJsonConverter()); + _jsonOptions.Converters.Add(new IsoscelesTriangleJsonConverter()); + _jsonOptions.Converters.Add(new ListJsonConverter()); + _jsonOptions.Converters.Add(new LiteralStringClassJsonConverter()); + _jsonOptions.Converters.Add(new MammalJsonConverter()); + _jsonOptions.Converters.Add(new MapTestJsonConverter()); + _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueJsonConverter()); + _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueNullableJsonConverter()); + _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); + _jsonOptions.Converters.Add(new ModelClientJsonConverter()); + _jsonOptions.Converters.Add(new NameJsonConverter()); + _jsonOptions.Converters.Add(new NotificationtestGetElementsV1ResponseMPayloadJsonConverter()); + _jsonOptions.Converters.Add(new NullableClassJsonConverter()); + _jsonOptions.Converters.Add(new NullableGuidClassJsonConverter()); + _jsonOptions.Converters.Add(new NullableShapeJsonConverter()); + _jsonOptions.Converters.Add(new NumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ObjectWithDeprecatedFieldsJsonConverter()); + _jsonOptions.Converters.Add(new OneOfStringJsonConverter()); + _jsonOptions.Converters.Add(new OrderJsonConverter()); + _jsonOptions.Converters.Add(new OrderStatusJsonConverter()); + _jsonOptions.Converters.Add(new OrderStatusNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterCompositeJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumDefaultValueJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumDefaultValueNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerDefaultValueJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerDefaultValueNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumTestJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumTestNullableJsonConverter()); + _jsonOptions.Converters.Add(new ParentPetJsonConverter()); + _jsonOptions.Converters.Add(new PetJsonConverter()); + _jsonOptions.Converters.Add(new PetStatusJsonConverter()); + _jsonOptions.Converters.Add(new PetStatusNullableJsonConverter()); + _jsonOptions.Converters.Add(new PigJsonConverter()); + _jsonOptions.Converters.Add(new PolymorphicPropertyJsonConverter()); + _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumIntegerJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumIntegerNullableJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumIntegerOnlyJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumIntegerOnlyNullableJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumStringJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNotnullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerNullableJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new ReturnJsonConverter()); + _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); + _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); + _jsonOptions.Converters.Add(new ScaleneTriangleJsonConverter()); + _jsonOptions.Converters.Add(new ShapeJsonConverter()); + _jsonOptions.Converters.Add(new ShapeInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new ShapeOrNullJsonConverter()); + _jsonOptions.Converters.Add(new SimpleQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new SpecialModelNameJsonConverter()); + _jsonOptions.Converters.Add(new TagJsonConverter()); + _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); + _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumHeaderStringParameterJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumHeaderStringParameterNullableJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumQueryDoubleParameterJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumQueryDoubleParameterNullableJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumQueryIntegerParameterJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersEnumQueryIntegerParameterNullableJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter()); + _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter()); + _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TriangleJsonConverter()); + _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new UserJsonConverter()); + _jsonOptions.Converters.Add(new WhaleJsonConverter()); + _jsonOptions.Converters.Add(new ZebraJsonConverter()); + _jsonOptions.Converters.Add(new ZebraTypeJsonConverter()); + _jsonOptions.Converters.Add(new ZebraTypeNullableJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumNullableJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumClassZeroBasedEnumJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumClassZeroBasedEnumNullableJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs new file mode 100644 index 000000000000..53f435c05f95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -0,0 +1,641 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Cryptography; +using System.Text; +using System.Web; + +namespace Org.OpenAPITools.Client +{ + /// + /// Class for HttpSigning auth related parameter and methods + /// + public class HttpSigningConfiguration + { + /// + /// Create an instance + /// + public HttpSigningConfiguration(string keyId, string keyFilePath, SecureString keyPassPhrase, List httpSigningHeader, HashAlgorithmName hashAlgorithm, string signingAlgorithm, int signatureValidityPeriod) + { + KeyId = keyId; + KeyFilePath = keyFilePath; + KeyPassPhrase = keyPassPhrase; + HttpSigningHeader = httpSigningHeader; + HashAlgorithm = hashAlgorithm; + SigningAlgorithm = signingAlgorithm; + SignatureValidityPeriod = signatureValidityPeriod; + } + + /// + ///Gets the Api keyId + /// + public string KeyId { get; set; } + + /// + /// Gets the Key file path + /// + public string KeyFilePath { get; set; } + + /// + /// Gets the key pass phrase for password protected key + /// + public SecureString KeyPassPhrase { get; set; } + + /// + /// Gets the HTTP signing header + /// + public List HttpSigningHeader { get; set; } + + /// + /// Gets the hash algorithm sha256 or sha512 + /// + public HashAlgorithmName HashAlgorithm { get; set; } = HashAlgorithmName.SHA256; + + /// + /// Gets the signing algorithm + /// + public string SigningAlgorithm { get; set; } + + /// + /// Gets the Signature validaty period in seconds + /// + public int SignatureValidityPeriod { get; set; } + + private enum PrivateKeyType + { + None = 0, + RSA = 1, + ECDSA = 2, + } + + /// + /// Gets the Headers for HttpSigning + /// + /// + /// + /// + internal Dictionary GetHttpSignedHeader(System.Net.Http.HttpRequestMessage request, string requestBody, System.Threading.CancellationToken cancellationToken = default) + { + if (request.RequestUri == null) + throw new NullReferenceException("The request URI was null"); + + const string HEADER_REQUEST_TARGET = "(request-target)"; + + // The time when the HTTP signature expires. The API server should reject HTTP requests that have expired. + const string HEADER_EXPIRES = "(expires)"; + + //The 'Date' header. + const string HEADER_DATE = "Date"; + + //The 'Host' header. + const string HEADER_HOST = "Host"; + + //The time when the HTTP signature was generated. + const string HEADER_CREATED = "(created)"; + + //When the 'Digest' header is included in the HTTP signature, the client automatically + //computes the digest of the HTTP request body, per RFC 3230. + const string HEADER_DIGEST = "Digest"; + + //The 'Authorization' header is automatically generated by the client. It includes + //the list of signed headers and a base64-encoded signature. + const string HEADER_AUTHORIZATION = "Authorization"; + + //Hash table to store singed headers + var HttpSignedRequestHeader = new Dictionary(); + + var httpSignatureHeader = new Dictionary(); + + if (HttpSigningHeader.Count == 0) + HttpSigningHeader.Add("(created)"); + + var dateTime = DateTime.Now; + string digest = String.Empty; + + if (HashAlgorithm == HashAlgorithmName.SHA256) + { + var bodyDigest = GetStringHash(HashAlgorithm, requestBody); + digest = string.Format("SHA-256={0}", Convert.ToBase64String(bodyDigest)); + } + else if (HashAlgorithm == HashAlgorithmName.SHA512) + { + var bodyDigest = GetStringHash(HashAlgorithm, requestBody); + digest = string.Format("SHA-512={0}", Convert.ToBase64String(bodyDigest)); + } + else + throw new Exception(string.Format("{0} not supported", HashAlgorithm)); + + foreach (var header in HttpSigningHeader) + if (header.Equals(HEADER_REQUEST_TARGET)) + httpSignatureHeader.Add(header.ToLower(), request.RequestUri.ToString()); + else if (header.Equals(HEADER_EXPIRES)) + { + var expireDateTime = dateTime.AddSeconds(SignatureValidityPeriod); + httpSignatureHeader.Add(header.ToLower(), GetUnixTime(expireDateTime).ToString()); + } + else if (header.Equals(HEADER_DATE)) + { + var utcDateTime = dateTime.ToString("r").ToString(); + httpSignatureHeader.Add(header.ToLower(), utcDateTime); + HttpSignedRequestHeader.Add(HEADER_DATE, utcDateTime); + } + else if (header.Equals(HEADER_HOST)) + { + httpSignatureHeader.Add(header.ToLower(), request.RequestUri.ToString()); + HttpSignedRequestHeader.Add(HEADER_HOST, request.RequestUri.ToString()); + } + else if (header.Equals(HEADER_CREATED)) + httpSignatureHeader.Add(header.ToLower(), GetUnixTime(dateTime).ToString()); + else if (header.Equals(HEADER_DIGEST)) + { + HttpSignedRequestHeader.Add(HEADER_DIGEST, digest); + httpSignatureHeader.Add(header.ToLower(), digest); + } + else + { + bool isHeaderFound = false; + foreach (var item in request.Headers) + { + if (string.Equals(item.Key, header, StringComparison.OrdinalIgnoreCase)) + { + httpSignatureHeader.Add(header.ToLower(), item.Value.ToString()); + isHeaderFound = true; + break; + } + } + + if (!isHeaderFound) + throw new Exception(string.Format("Cannot sign HTTP request.Request does not contain the {0} header.",header)); + } + + var headersKeysString = String.Join(" ", httpSignatureHeader.Keys); + var headerValuesList = new List(); + + foreach (var keyVal in httpSignatureHeader) + headerValuesList.Add(string.Format("{0}: {1}", keyVal.Key, keyVal.Value)); + + //Concatenate headers value separated by new line + var headerValuesString = string.Join("\n", headerValuesList); + var signatureStringHash = GetStringHash(HashAlgorithm, headerValuesString); + string headerSignatureStr = null; + var keyType = GetKeyType(KeyFilePath); + + if (keyType == PrivateKeyType.RSA) + headerSignatureStr = GetRSASignature(signatureStringHash); + + else if (keyType == PrivateKeyType.ECDSA) + headerSignatureStr = GetECDSASignature(signatureStringHash); + + var cryptographicScheme = "hs2019"; + var authorizationHeaderValue = string.Format("Signature keyId=\"{0}\",algorithm=\"{1}\"", + KeyId, cryptographicScheme); + + if (httpSignatureHeader.ContainsKey(HEADER_CREATED)) + authorizationHeaderValue += string.Format(",created={0}", httpSignatureHeader[HEADER_CREATED]); + + if (httpSignatureHeader.ContainsKey(HEADER_EXPIRES)) + authorizationHeaderValue += string.Format(",expires={0}", httpSignatureHeader[HEADER_EXPIRES]); + + authorizationHeaderValue += string.Format(",headers=\"{0}\",signature=\"{1}\"", headersKeysString, headerSignatureStr); + + HttpSignedRequestHeader.Add(HEADER_AUTHORIZATION, authorizationHeaderValue); + + return HttpSignedRequestHeader; + } + + private byte[] GetStringHash(HashAlgorithmName hashAlgorithmName, string stringToBeHashed) + { + HashAlgorithm hashAlgorithm = null; + + if (hashAlgorithmName == HashAlgorithmName.SHA1) + hashAlgorithm = SHA1.Create(); + + if (hashAlgorithmName == HashAlgorithmName.SHA256) + hashAlgorithm = SHA256.Create(); + + if (hashAlgorithmName == HashAlgorithmName.SHA512) + hashAlgorithm = SHA512.Create(); + + if (hashAlgorithmName == HashAlgorithmName.MD5) + hashAlgorithm = MD5.Create(); + + if (hashAlgorithm == null) + throw new NullReferenceException($"{ nameof(hashAlgorithm) } was null."); + + byte[] bytes = Encoding.UTF8.GetBytes(stringToBeHashed); + byte[] stringHash = hashAlgorithm.ComputeHash(bytes); + return stringHash; + } + + private int GetUnixTime(DateTime date2) + { + DateTime date1 = new DateTime(1970, 01, 01); + TimeSpan timeSpan = date2 - date1; + return (int)timeSpan.TotalSeconds; + } + + private string GetRSASignature(byte[] stringToSign) + { + if (KeyPassPhrase == null) + throw new NullReferenceException($"{ nameof(KeyPassPhrase) } was null."); + + RSA rsa = GetRSAProviderFromPemFile(KeyFilePath, KeyPassPhrase); + + if (rsa == null) + return string.Empty; + else if (SigningAlgorithm == "RSASSA-PSS") + { + var signedbytes = rsa.SignHash(stringToSign, HashAlgorithm, RSASignaturePadding.Pss); + return Convert.ToBase64String(signedbytes); + } + else if (SigningAlgorithm == "PKCS1-v15") + { + var signedbytes = rsa.SignHash(stringToSign, HashAlgorithm, RSASignaturePadding.Pkcs1); + return Convert.ToBase64String(signedbytes); + } + + return string.Empty; + } + + /// + /// Gets the ECDSA signature + /// + /// + /// + private string GetECDSASignature(byte[] dataToSign) + { + throw new Exception("ECDSA signing is supported only on NETCOREAPP3_0 and above"); + } + + private byte[] ConvertToECDSAANS1Format(byte[] signedBytes) + { + var derBytes = new List(); + byte derLength = 68; //default length for ECDSA code signing bit 0x44 + byte rbytesLength = 32; //R length 0x20 + byte sbytesLength = 32; //S length 0x20 + var rBytes = new List(); + var sBytes = new List(); + for (int i = 0; i < 32; i++) + rBytes.Add(signedBytes[i]); + + for (int i = 32; i < 64; i++) + sBytes.Add(signedBytes[i]); + + if (rBytes[0] > 0x7F) + { + derLength++; + rbytesLength++; + var tempBytes = new List(); + tempBytes.AddRange(rBytes); + rBytes.Clear(); + rBytes.Add(0x00); + rBytes.AddRange(tempBytes); + } + + if (sBytes[0] > 0x7F) + { + derLength++; + sbytesLength++; + var tempBytes = new List(); + tempBytes.AddRange(sBytes); + sBytes.Clear(); + sBytes.Add(0x00); + sBytes.AddRange(tempBytes); + + } + + derBytes.Add(48); //start of the sequence 0x30 + derBytes.Add(derLength); //total length r length, type and r bytes + + derBytes.Add(2); //tag for integer + derBytes.Add(rbytesLength); //length of r + derBytes.AddRange(rBytes); + + derBytes.Add(2); //tag for integer + derBytes.Add(sbytesLength); //length of s + derBytes.AddRange(sBytes); + return derBytes.ToArray(); + } + + private RSACryptoServiceProvider GetRSAProviderFromPemFile(String pemfile, SecureString keyPassPhrase = null) + { + const String pempubheader = "-----BEGIN PUBLIC KEY-----"; + const String pempubfooter = "-----END PUBLIC KEY-----"; + bool isPrivateKeyFile = true; + byte[] pemkey = null; + + if (!File.Exists(pemfile)) + throw new Exception("private key file does not exist."); + + string pemstr = File.ReadAllText(pemfile).Trim(); + + if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) + isPrivateKeyFile = false; + + if (isPrivateKeyFile) + { + pemkey = ConvertPrivateKeyToBytes(pemstr, keyPassPhrase); + + if (pemkey == null) + return null; + + return DecodeRSAPrivateKey(pemkey); + } + return null; + } + + private byte[] ConvertPrivateKeyToBytes(String instr, SecureString keyPassPhrase = null) + { + const String pemprivheader = "-----BEGIN RSA PRIVATE KEY-----"; + const String pemprivfooter = "-----END RSA PRIVATE KEY-----"; + String pemstr = instr.Trim(); + byte[] binkey; + + if (!pemstr.StartsWith(pemprivheader) || !pemstr.EndsWith(pemprivfooter)) + return null; + + StringBuilder sb = new StringBuilder(pemstr); + sb.Replace(pemprivheader, ""); + sb.Replace(pemprivfooter, ""); + String pvkstr = sb.ToString().Trim(); + + try + { // if there are no PEM encryption info lines, this is an UNencrypted PEM private key + binkey = Convert.FromBase64String(pvkstr); + return binkey; + } + catch (System.FormatException) + { + StringReader str = new StringReader(pvkstr); + + //-------- read PEM encryption info. lines and extract salt ----- + if (!str.ReadLine().StartsWith("Proc-Type: 4,ENCRYPTED")) // TODO: what do we do here if ReadLine is null? + return null; + + String saltline = str.ReadLine(); // TODO: what do we do here if ReadLine is null? + if (!saltline.StartsWith("DEK-Info: DES-EDE3-CBC,")) + return null; + + String saltstr = saltline.Substring(saltline.IndexOf(",") + 1).Trim(); + byte[] salt = new byte[saltstr.Length / 2]; + for (int i = 0; i < salt.Length; i++) + salt[i] = Convert.ToByte(saltstr.Substring(i * 2, 2), 16); + + if (!(str.ReadLine() == "")) + return null; + + //------ remaining b64 data is encrypted RSA key ---- + String encryptedstr = str.ReadToEnd(); + + try + { //should have b64 encrypted RSA key now + binkey = Convert.FromBase64String(encryptedstr); + } + catch (System.FormatException) + { //data is not in base64 format + return null; + } + + // TODO: what do we do here if keyPassPhrase is null? + byte[] deskey = GetEncryptedKey(salt, keyPassPhrase, 1, 2); // count=1 (for OpenSSL implementation); 2 iterations to get at least 24 bytes + if (deskey == null) + return null; + + //------ Decrypt the encrypted 3des-encrypted RSA private key ------ + byte[] rsakey = DecryptKey(binkey, deskey, salt); //OpenSSL uses salt value in PEM header also as 3DES IV + + return rsakey; + } + } + + private RSACryptoServiceProvider DecodeRSAPrivateKey(byte[] privkey) + { + byte[] MODULUS, E, D, P, Q, DP, DQ, IQ; + + // --------- Set up stream to decode the asn.1 encoded RSA private key ------ + MemoryStream mem = new MemoryStream(privkey); + BinaryReader binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading + byte bt = 0; + ushort twobytes = 0; + int elems = 0; + try + { + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + return null; + + twobytes = binr.ReadUInt16(); + if (twobytes != 0x0102) //version number + return null; + + bt = binr.ReadByte(); + if (bt != 0x00) + return null; + + //------ all private key components are Integer sequences ---- + elems = GetIntegerSize(binr); + MODULUS = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + E = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + D = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + P = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + Q = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + DP = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + DQ = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + IQ = binr.ReadBytes(elems); + + // ------- create RSACryptoServiceProvider instance and initialize with public key ----- + RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); + RSAParameters RSAparams = new RSAParameters(); + RSAparams.Modulus = MODULUS; + RSAparams.Exponent = E; + RSAparams.D = D; + RSAparams.P = P; + RSAparams.Q = Q; + RSAparams.DP = DP; + RSAparams.DQ = DQ; + RSAparams.InverseQ = IQ; + RSA.ImportParameters(RSAparams); + return RSA; + } + catch (Exception) + { + return null; + } + finally + { + binr.Close(); + } + } + + private int GetIntegerSize(BinaryReader binr) + { + byte bt = 0; + byte lowbyte = 0x00; + byte highbyte = 0x00; + int count = 0; + bt = binr.ReadByte(); + if (bt != 0x02) //expect integer + return 0; + + bt = binr.ReadByte(); + + if (bt == 0x81) + count = binr.ReadByte(); // data size in next byte + else if (bt == 0x82) + { + highbyte = binr.ReadByte(); // data size in next 2 bytes + lowbyte = binr.ReadByte(); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; + count = BitConverter.ToInt32(modint, 0); + } + else + count = bt; // we already have the data size + + while (binr.ReadByte() == 0x00) + //remove high order zeros in data + count -= 1; + + binr.BaseStream.Seek(-1, SeekOrigin.Current); + + //last ReadByte wasn't a removed zero, so back up a byte + return count; + } + + private byte[] GetEncryptedKey(byte[] salt, SecureString secpswd, int count, int miter) + { + IntPtr unmanagedPswd = IntPtr.Zero; + int HASHLENGTH = 16; //MD5 bytes + byte[] keymaterial = new byte[HASHLENGTH * miter]; //to store concatenated Mi hashed results + + byte[] psbytes = new byte[secpswd.Length]; + unmanagedPswd = Marshal.SecureStringToGlobalAllocAnsi(secpswd); + Marshal.Copy(unmanagedPswd, psbytes, 0, psbytes.Length); + Marshal.ZeroFreeGlobalAllocAnsi(unmanagedPswd); + + // --- concatenate salt and pswd bytes into fixed data array --- + byte[] data00 = new byte[psbytes.Length + salt.Length]; + Array.Copy(psbytes, data00, psbytes.Length); //copy the pswd bytes + Array.Copy(salt, 0, data00, psbytes.Length, salt.Length); //concatenate the salt bytes + + // ---- do multi-hashing and concatenate results D1, D2 ... into keymaterial bytes ---- + MD5 md5 = MD5.Create(); + byte[] result = null; + byte[] hashtarget = new byte[HASHLENGTH + data00.Length]; //fixed length initial hashtarget + + for (int j = 0; j < miter; j++) + { + // ---- Now hash consecutively for count times ------ + if (j == 0) + result = data00; //initialize + else + { + Array.Copy(result, hashtarget, result.Length); // TODO: what do we do if result is null here? + Array.Copy(data00, 0, hashtarget, result.Length, data00.Length); + result = hashtarget; + } + + for (int i = 0; i < count; i++) + result = md5.ComputeHash(result); + + Array.Copy(result, 0, keymaterial, j * HASHLENGTH, result.Length); //concatenate to keymaterial + } + byte[] deskey = new byte[24]; + Array.Copy(keymaterial, deskey, deskey.Length); + + Array.Clear(psbytes, 0, psbytes.Length); + Array.Clear(data00, 0, data00.Length); + Array.Clear(result, 0, result.Length); // TODO: what do we do if result is null here? + Array.Clear(hashtarget, 0, hashtarget.Length); + Array.Clear(keymaterial, 0, keymaterial.Length); + return deskey; + } + + private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) + { + MemoryStream memst = new MemoryStream(); + TripleDES alg = TripleDES.Create(); + alg.Key = desKey; + alg.IV = IV; + try + { + CryptoStream cs = new CryptoStream(memst, alg.CreateDecryptor(), CryptoStreamMode.Write); + cs.Write(cipherData, 0, cipherData.Length); + cs.Close(); + } + catch (Exception) + { + return null; + } + byte[] decryptedData = memst.ToArray(); + return decryptedData; + } + + /// + /// Detect the key type from the pem file. + /// + /// key file path in pem format + /// + private PrivateKeyType GetKeyType(string keyFilePath) + { + if (!File.Exists(keyFilePath)) + throw new Exception("Key file path does not exist."); + + var ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; + var ecPrivateKeyFooter = "END EC PRIVATE KEY"; + var rsaPrivateKeyHeader = "BEGIN RSA PRIVATE KEY"; + var rsaPrivateFooter = "END RSA PRIVATE KEY"; + //var pkcs8Header = "BEGIN PRIVATE KEY"; + //var pkcs8Footer = "END PRIVATE KEY"; + var keyType = PrivateKeyType.None; + var key = File.ReadAllLines(keyFilePath); + + if (key[0].ToString().Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) + keyType = PrivateKeyType.RSA; + else if (key[0].ToString().Contains(ecPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(ecPrivateKeyFooter)) + keyType = PrivateKeyType.ECDSA; + + else if (key[0].ToString().Contains(ecPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(ecPrivateKeyFooter)) + { + /* this type of key can hold many type different types of private key, but here due lack of pem header + Considering this as EC key + */ + //TODO :- update the key based on oid + keyType = PrivateKeyType.ECDSA; + } + else + throw new Exception("Either the key is invalid or key is not supported"); + + return keyType; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningToken.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningToken.cs new file mode 100644 index 000000000000..b6301dc17c95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HttpSigningToken.cs @@ -0,0 +1,41 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from an HttpSigningConfiguration + /// + public class HttpSignatureToken : TokenBase + { + private HttpSigningConfiguration _configuration; + + /// + /// Constructs an HttpSignatureToken object. + /// + /// + /// + public HttpSignatureToken(HttpSigningConfiguration configuration, TimeSpan? timeout = null) : base(timeout) + { + _configuration = configuration; + } + + /// + /// Places the token in the header. + /// + /// + /// + /// + public void UseInHeader(System.Net.Http.HttpRequestMessage request, string requestBody, CancellationToken cancellationToken = default) + { + var signedHeaders = _configuration.GetHttpSignedHeader(request, requestBody, cancellationToken); + + foreach (var signedHeader in signedHeaders) + request.Headers.Add(signedHeader.Key, signedHeader.Value); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/OAuthToken.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/OAuthToken.cs new file mode 100644 index 000000000000..ec4d08e9c99a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/OAuthToken.cs @@ -0,0 +1,37 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed with OAuth. + /// + public class OAuthToken : TokenBase + { + private string _raw; + + /// + /// Consturcts an OAuthToken object. + /// + /// + /// + public OAuthToken(string value, TimeSpan? timeout = null) : base(timeout) + { + _raw = value; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _raw); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..8cf79a713b74 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..534f27a8cc52 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,72 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + if (container is TokenContainer apiKeyTokenContainer) + { + string[] headers = apiKeyTokenContainer.Tokens.Select(t => ClientUtils.ApiKeyHeaderToString(t.Header)).Distinct().ToArray(); + + foreach (string header in headers) + { + BoundedChannelOptions options = new BoundedChannelOptions(apiKeyTokenContainer.Tokens.Count(t => ClientUtils.ApiKeyHeaderToString(t.Header).Equals(header))) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(header, Channel.CreateBounded(options)); + } + } + else + { + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + } + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..36d7dad03e23 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..dce7b971eaac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,41 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..40eeffc96765 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..c82fea7a865d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs new file mode 100644 index 000000000000..2e4d5cb3bb8f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Activity.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// test map of maps + /// + public partial class Activity : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// activityOutputs + [JsonConstructor] + public Activity(Option>> activityOutputs = default) + { + ActivityOutputsOption = activityOutputs; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ActivityOutputsOption { get; private set; } + + /// + /// Gets or Sets ActivityOutputs + /// + [JsonPropertyName("activity_outputs")] + public Dictionary> ActivityOutputs { get { return this.ActivityOutputsOption; } set { this.ActivityOutputsOption = new Option>>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Activity {\n"); + sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> activityOutputs = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "activity_outputs": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + activityOutputs = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); + + return new Activity(activityOutputs); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, activity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + { + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs new file mode 100644 index 000000000000..b24ba8678984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -0,0 +1,207 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ActivityOutputElementRepresentation + /// + public partial class ActivityOutputElementRepresentation : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// prop1 + /// prop2 + [JsonConstructor] + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) + { + Prop1Option = prop1; + Prop2Option = prop2; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + + /// + /// Gets or Sets Prop1 + /// + [JsonPropertyName("prop1")] + public string Prop1 { get { return this.Prop1Option; } set { this.Prop1Option = new Option(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } + + /// + /// Gets or Sets Prop2 + /// + [JsonPropertyName("prop2")] + public Object Prop2 { get { return this.Prop2Option; } set { this.Prop2Option = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ActivityOutputElementRepresentation {\n"); + sb.Append(" Prop1: ").Append(Prop1).Append("\n"); + sb.Append(" Prop2: ").Append(Prop2).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ActivityOutputElementRepresentationJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option prop1 = default; + Option prop2 = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "prop1": + prop1 = new Option(utf8JsonReader.GetString()); + break; + case "prop2": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); + + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); + + return new ActivityOutputElementRepresentation(prop1, prop2); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + { + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs new file mode 100644 index 000000000000..dcc268fc3a8d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -0,0 +1,400 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// AdditionalPropertiesClass + /// + public partial class AdditionalPropertiesClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// anytype1 + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// mapOfMapProperty + /// mapProperty + /// mapWithUndeclaredPropertiesAnytype1 + /// mapWithUndeclaredPropertiesAnytype2 + /// mapWithUndeclaredPropertiesAnytype3 + /// mapWithUndeclaredPropertiesString + [JsonConstructor] + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>> mapOfMapProperty = default, Option> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option> mapWithUndeclaredPropertiesAnytype3 = default, Option> mapWithUndeclaredPropertiesString = default) + { + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Anytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } + + /// + /// Gets or Sets Anytype1 + /// + [JsonPropertyName("anytype_1")] + public Object Anytype1 { get { return this.Anytype1Option; } set { this.Anytype1Option = new Option(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object EmptyMap { get { return this.EmptyMapOption; } set { this.EmptyMapOption = new Option(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary> MapOfMapProperty { get { return this.MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new Option>>(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary MapProperty { get { return this.MapPropertyOption; } set { this.MapPropertyOption = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object MapWithUndeclaredPropertiesAnytype1 { get { return this.MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object MapWithUndeclaredPropertiesAnytype2 { get { return this.MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary MapWithUndeclaredPropertiesAnytype3 { get { return this.MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary MapWithUndeclaredPropertiesString { get { return this.MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); + sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); + sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); + sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype1: ").Append(MapWithUndeclaredPropertiesAnytype1).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AdditionalPropertiesClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option anytype1 = default; + Option emptyMap = default; + Option>> mapOfMapProperty = default; + Option> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option> mapWithUndeclaredPropertiesAnytype3 = default; + Option> mapWithUndeclaredPropertiesString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "empty_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_of_map_property": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapOfMapProperty = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_property": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapProperty = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_2": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_3": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype3 = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); + + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs new file mode 100644 index 000000000000..29362b0ca361 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Animal.cs @@ -0,0 +1,221 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Animal + /// + public partial class Animal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// color (default to "red") + [JsonConstructor] + public Animal(Option color = default) + { + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AnimalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option color = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "className"); + + if (discriminator != null && discriminator.Equals("Cat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + if (discriminator != null && discriminator.Equals("Dog")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + { + if (animal is Cat cat){ + JsonSerializer.Serialize(writer, cat, jsonSerializerOptions); + return; + } + + if (animal is Dog dog){ + JsonSerializer.Serialize(writer, dog, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, animal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + { + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + + writer.WriteString("className", animal.ClassName); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs new file mode 100644 index 000000000000..f63a202f3973 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -0,0 +1,230 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ApiResponse + /// + public partial class ApiResponse : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// message + /// type + [JsonConstructor] + public ApiResponse(Option code = default, Option message = default, Option type = default) + { + CodeOption = code; + MessageOption = message; + TypeOption = type; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public int? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } + + /// + /// Gets or Sets Message + /// + [JsonPropertyName("message")] + public string Message { get { return this.MessageOption; } set { this.MessageOption = new Option(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + + /// + /// Gets or Sets Type + /// + [JsonPropertyName("type")] + public string Type { get { return this.TypeOption; } set { this.TypeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ApiResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option code = default; + Option message = default; + Option type = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "code": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + code = new Option(utf8JsonReader.GetInt32()); + break; + case "message": + message = new Option(utf8JsonReader.GetString()); + break; + case "type": + type = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); + + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); + + return new ApiResponse(code, message, type); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apiResponse, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + { + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs new file mode 100644 index 000000000000..87e58a000210 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Apple.cs @@ -0,0 +1,262 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Apple + /// + public partial class Apple : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// colorCode + /// cultivar + /// origin + [JsonConstructor] + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) + { + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + + /// + /// Gets or Sets ColorCode + /// + [JsonPropertyName("color_code")] + public string ColorCode { get { return this.ColorCodeOption; } set { this.ColorCodeOption = new Option(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } + + /// + /// Gets or Sets Cultivar + /// + [JsonPropertyName("cultivar")] + public string Cultivar { get { return this.CultivarOption; } set { this.CultivarOption = new Option(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } + + /// + /// Gets or Sets Origin + /// + [JsonPropertyName("origin")] + public string Origin { get { return this.OriginOption; } set { this.OriginOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Apple {\n"); + sb.Append(" ColorCode: ").Append(ColorCode).Append("\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); + sb.Append(" Origin: ").Append(Origin).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + if (this.ColorCodeOption.Value != null) { + // ColorCode (string) pattern + Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); + } + } + + if (this.CultivarOption.Value != null) { + // Cultivar (string) pattern + Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); + } + } + + if (this.OriginOption.Value != null) { + // Origin (string) pattern + Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); + } + } + + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option colorCode = default; + Option cultivar = default; + Option origin = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color_code": + colorCode = new Option(utf8JsonReader.GetString()); + break; + case "cultivar": + cultivar = new Option(utf8JsonReader.GetString()); + break; + case "origin": + origin = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); + + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); + + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); + + return new Apple(colorCode, cultivar, origin); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apple, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs new file mode 100644 index 000000000000..6a2e8b75f6da --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// AppleReq + /// + public partial class AppleReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// cultivar + /// mealy + [JsonConstructor] + public AppleReq(string cultivar, Option mealy = default) + { + Cultivar = cultivar; + MealyOption = mealy; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Cultivar + /// + [JsonPropertyName("cultivar")] + public string Cultivar { get; set; } + + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + + /// + /// Gets or Sets Mealy + /// + [JsonPropertyName("mealy")] + public bool? Mealy { get { return this.MealyOption; } set { this.MealyOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class AppleReq {\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); + sb.Append(" Mealy: ").Append(Mealy).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option cultivar = default; + Option mealy = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "cultivar": + cultivar = new Option(utf8JsonReader.GetString()); + break; + case "mealy": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mealy = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); + + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); + + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value, mealy); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, appleReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + + writer.WriteString("cultivar", appleReq.Cultivar); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs new file mode 100644 index 000000000000..d66d69222da8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayOfArrayOfNumberOnly + /// + public partial class ArrayOfArrayOfNumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayArrayNumber + [JsonConstructor] + public ArrayOfArrayOfNumberOnly(Option>> arrayArrayNumber = default) + { + ArrayArrayNumberOption = arrayArrayNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayNumberOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayNumber + /// + [JsonPropertyName("ArrayArrayNumber")] + public List> ArrayArrayNumber { get { return this.ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new Option>>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayOfArrayOfNumberOnly {\n"); + sb.Append(" ArrayArrayNumber: ").Append(ArrayArrayNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayOfArrayOfNumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> arrayArrayNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ArrayArrayNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayNumber = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); + + return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs new file mode 100644 index 000000000000..7ec6a05f2420 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayOfNumberOnly + /// + public partial class ArrayOfNumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayNumber + [JsonConstructor] + public ArrayOfNumberOnly(Option> arrayNumber = default) + { + ArrayNumberOption = arrayNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNumberOption { get; private set; } + + /// + /// Gets or Sets ArrayNumber + /// + [JsonPropertyName("ArrayNumber")] + public List ArrayNumber { get { return this.ArrayNumberOption; } set { this.ArrayNumberOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayOfNumberOnly {\n"); + sb.Append(" ArrayNumber: ").Append(ArrayNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayOfNumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ArrayNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayNumber = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); + + return new ArrayOfNumberOnly(arrayNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs new file mode 100644 index 000000000000..0ae28dc07d59 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -0,0 +1,242 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayTest + /// + public partial class ArrayTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayArrayOfInteger + /// arrayArrayOfModel + /// arrayOfString + [JsonConstructor] + public ArrayTest(Option>> arrayArrayOfInteger = default, Option>> arrayArrayOfModel = default, Option> arrayOfString = default) + { + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfIntegerOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayOfInteger + /// + [JsonPropertyName("array_array_of_integer")] + public List> ArrayArrayOfInteger { get { return this.ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfModelOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayOfModel + /// + [JsonPropertyName("array_array_of_model")] + public List> ArrayArrayOfModel { get { return this.ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets ArrayOfString + /// + [JsonPropertyName("array_of_string")] + public List ArrayOfString { get { return this.ArrayOfStringOption; } set { this.ArrayOfStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayTest {\n"); + sb.Append(" ArrayArrayOfInteger: ").Append(ArrayArrayOfInteger).Append("\n"); + sb.Append(" ArrayArrayOfModel: ").Append(ArrayArrayOfModel).Append("\n"); + sb.Append(" ArrayOfString: ").Append(ArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> arrayArrayOfInteger = default; + Option>> arrayArrayOfModel = default; + Option> arrayOfString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_array_of_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayOfInteger = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_array_of_model": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayOfModel = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); + + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); + + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); + + return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs new file mode 100644 index 000000000000..f8f25778428e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Banana.cs @@ -0,0 +1,172 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Banana + /// + public partial class Banana : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lengthCm + [JsonConstructor] + public Banana(Option lengthCm = default) + { + LengthCmOption = lengthCm; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + + /// + /// Gets or Sets LengthCm + /// + [JsonPropertyName("lengthCm")] + public decimal? LengthCm { get { return this.LengthCmOption; } set { this.LengthCmOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Banana {\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option lengthCm = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lengthCm": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + lengthCm = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); + + return new Banana(lengthCm); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, banana, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs new file mode 100644 index 000000000000..848e8164b4ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs @@ -0,0 +1,187 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// BananaReq + /// + public partial class BananaReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lengthCm + /// sweet + [JsonConstructor] + public BananaReq(decimal lengthCm, Option sweet = default) + { + LengthCm = lengthCm; + SweetOption = sweet; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets LengthCm + /// + [JsonPropertyName("lengthCm")] + public decimal LengthCm { get; set; } + + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + + /// + /// Gets or Sets Sweet + /// + [JsonPropertyName("sweet")] + public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class BananaReq {\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); + sb.Append(" Sweet: ").Append(Sweet).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option lengthCm = default; + Option sweet = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lengthCm": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + lengthCm = new Option(utf8JsonReader.GetDecimal()); + break; + case "sweet": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + sweet = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); + + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); + + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value.Value, sweet); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, bananaReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteNumber("lengthCm", bananaReq.LengthCm); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs new file mode 100644 index 000000000000..863cc82bc782 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// BasquePig + /// + public partial class BasquePig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + [JsonConstructor] + public BasquePig(string className) + { + ClassName = className; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class BasquePig {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BasquePigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override BasquePig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, basquePig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + + writer.WriteString("className", basquePig.ClassName); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs new file mode 100644 index 000000000000..f24497e3ad68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs @@ -0,0 +1,320 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Capitalization + /// + public partial class Capitalization : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Name of the pet + /// capitalCamel + /// capitalSnake + /// sCAETHFlowPoints + /// smallCamel + /// smallSnake + [JsonConstructor] + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) + { + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + + /// + /// Name of the pet + /// + /// Name of the pet + [JsonPropertyName("ATT_NAME")] + public string ATT_NAME { get { return this.ATT_NAMEOption; } set { this.ATT_NAMEOption = new Option(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } + + /// + /// Gets or Sets CapitalCamel + /// + [JsonPropertyName("CapitalCamel")] + public string CapitalCamel { get { return this.CapitalCamelOption; } set { this.CapitalCamelOption = new Option(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } + + /// + /// Gets or Sets CapitalSnake + /// + [JsonPropertyName("Capital_Snake")] + public string CapitalSnake { get { return this.CapitalSnakeOption; } set { this.CapitalSnakeOption = new Option(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } + + /// + /// Gets or Sets SCAETHFlowPoints + /// + [JsonPropertyName("SCA_ETH_Flow_Points")] + public string SCAETHFlowPoints { get { return this.SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new Option(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } + + /// + /// Gets or Sets SmallCamel + /// + [JsonPropertyName("smallCamel")] + public string SmallCamel { get { return this.SmallCamelOption; } set { this.SmallCamelOption = new Option(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } + + /// + /// Gets or Sets SmallSnake + /// + [JsonPropertyName("small_Snake")] + public string SmallSnake { get { return this.SmallSnakeOption; } set { this.SmallSnakeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Capitalization {\n"); + sb.Append(" ATT_NAME: ").Append(ATT_NAME).Append("\n"); + sb.Append(" CapitalCamel: ").Append(CapitalCamel).Append("\n"); + sb.Append(" CapitalSnake: ").Append(CapitalSnake).Append("\n"); + sb.Append(" SCAETHFlowPoints: ").Append(SCAETHFlowPoints).Append("\n"); + sb.Append(" SmallCamel: ").Append(SmallCamel).Append("\n"); + sb.Append(" SmallSnake: ").Append(SmallSnake).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class CapitalizationJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ATT_NAME": + aTTNAME = new Option(utf8JsonReader.GetString()); + break; + case "CapitalCamel": + capitalCamel = new Option(utf8JsonReader.GetString()); + break; + case "Capital_Snake": + capitalSnake = new Option(utf8JsonReader.GetString()); + break; + case "SCA_ETH_Flow_Points": + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()); + break; + case "smallCamel": + smallCamel = new Option(utf8JsonReader.GetString()); + break; + case "small_Snake": + smallSnake = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); + + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); + + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); + + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); + + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); + + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); + + return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, capitalization, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + { + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs new file mode 100644 index 000000000000..d11d16c855e0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Cat.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Cat + /// + public partial class Cat : Animal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// color (default to "red") + /// declawed + [JsonConstructor] + public Cat(Option color = default, Option declawed = default) : base(color) + { + DeclawedOption = declawed; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string ClassName { get; } = "Cat"; + + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + + /// + /// Gets or Sets Declawed + /// + [JsonPropertyName("declawed")] + public bool? Declawed { get { return this.DeclawedOption; } set { this.DeclawedOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CatJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option color = default; + Option declawed = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + case "declawed": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + declawed = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); + + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(color, declawed); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, cat, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + { + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + + writer.WriteString("className", cat.ClassName); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs new file mode 100644 index 000000000000..667e094c6ff4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Category.cs @@ -0,0 +1,196 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Category + /// + public partial class Category : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + /// name (default to "default-name") + [JsonConstructor] + public Category(Option id = default, string name = @"default-name") + { + IdOption = id; + Name = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class CategoryJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option id = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, category, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + { + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value.Value); + + writer.WriteString("name", category.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs new file mode 100644 index 000000000000..437e8188ab46 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs @@ -0,0 +1,179 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ChildCat + /// + public partial class ChildCat : ParentPet, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public ChildCat(Option name = default) : base() + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new ChildCatAllOfPetType PetType { get; } = (ChildCatAllOfPetType)Enum.Parse(typeof(ChildCatAllOfPetType), "ChildCat"); + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ChildCat {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class ChildCatJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option petType = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "pet_type": + string petTypeRawValue = utf8JsonReader.GetString(); + if (petTypeRawValue != null) + petType = new Option(ChildCatAllOfPetTypeValueConverter.FromStringOrDefault(petTypeRawValue)); + break; + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ChildCat.", nameof(petType)); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); + + return new ChildCat(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, childCat, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + { + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); + + writer.WriteString("pet_type", ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType)); + + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs new file mode 100644 index 000000000000..9e8bc253fdb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs @@ -0,0 +1,160 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines ChildCat_allOf_pet_type + /// + public enum ChildCatAllOfPetType + { + /// + /// Enum ChildCat for value: ChildCat + /// + ChildCat = 1 + } + + /// + /// Converts to and from the JSON value + /// + public static class ChildCatAllOfPetTypeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static ChildCatAllOfPetType FromString(string value) + { + if (value.Equals("ChildCat")) + return ChildCatAllOfPetType.ChildCat; + + throw new NotImplementedException($"Could not convert value to type ChildCatAllOfPetType: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static ChildCatAllOfPetType? FromStringOrDefault(string value) + { + if (value.Equals("ChildCat")) + return ChildCatAllOfPetType.ChildCat; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(ChildCatAllOfPetType value) + { + if (value == ChildCatAllOfPetType.ChildCat) + return "ChildCat"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class ChildCatAllOfPetTypeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override ChildCatAllOfPetType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ChildCatAllOfPetType? result = rawValue == null + ? null + : ChildCatAllOfPetTypeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the ChildCatAllOfPetType to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCatAllOfPetType childCatAllOfPetType, JsonSerializerOptions options) + { + writer.WriteStringValue(childCatAllOfPetType.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class ChildCatAllOfPetTypeNullableJsonConverter : JsonConverter + { + /// + /// Returns a ChildCatAllOfPetType from the Json object + /// + /// + /// + /// + /// + public override ChildCatAllOfPetType? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ChildCatAllOfPetType? result = rawValue == null + ? null + : ChildCatAllOfPetTypeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCatAllOfPetType? childCatAllOfPetType, JsonSerializerOptions options) + { + writer.WriteStringValue(childCatAllOfPetType?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs new file mode 100644 index 000000000000..9e254109cfcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model with \"_class\" property + /// + public partial class ClassModel : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// class + [JsonConstructor] + public ClassModel(Option @class = default) + { + ClassOption = @class; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Class + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ClassOption { get; private set; } + + /// + /// Gets or Sets Class + /// + [JsonPropertyName("_class")] + public string Class { get { return this.ClassOption; } set { this.ClassOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ClassModel {\n"); + sb.Append(" Class: ").Append(Class).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ClassModelJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClass = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "_class": + varClass = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); + + return new ClassModel(varClass); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, classModel, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + { + if (classModel.ClassOption.IsSet && classModel.Class == null) + throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel."); + + if (classModel.ClassOption.IsSet) + writer.WriteString("_class", classModel.Class); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs new file mode 100644 index 000000000000..1a42f967ca91 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ComplexQuadrilateral + /// + public partial class ComplexQuadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + /// shapeType + [JsonConstructor] + public ComplexQuadrilateral(string quadrilateralType, string shapeType) + { + QuadrilateralType = quadrilateralType; + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ComplexQuadrilateral {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ComplexQuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ComplexQuadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value, shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs new file mode 100644 index 000000000000..9eb8b733358d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DanishPig + /// + public partial class DanishPig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + [JsonConstructor] + public DanishPig(string className) + { + ClassName = className; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DanishPig {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DanishPigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DanishPig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, danishPig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + + writer.WriteString("className", danishPig.ClassName); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..c82942faae75 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + public partial class DateOnlyClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty + [JsonConstructor] + public DateOnlyClass(Option dateOnlyProperty = default) + { + DateOnlyPropertyOption = dateOnlyProperty; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + + /// + /// Gets or Sets DateOnlyProperty + /// + /// Fri Jul 21 00:00:00 UTC 2017 + [JsonPropertyName("dateOnlyProperty")] + public DateTime? DateOnlyProperty { get { return this.DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DateOnlyClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateOnlyProperty + /// + public static string DateOnlyPropertyFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option dateOnlyProperty = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "dateOnlyProperty": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); + + return new DateOnlyClass(dateOnlyProperty); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs new file mode 100644 index 000000000000..064985cce436 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DeprecatedObject + /// + public partial class DeprecatedObject : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public DeprecatedObject(Option name = default) + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DeprecatedObject {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DeprecatedObjectJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); + + return new DeprecatedObject(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + { + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs new file mode 100644 index 000000000000..75a60416f90c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Dog.cs @@ -0,0 +1,191 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Dog + /// + public partial class Dog : Animal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// breed + /// color (default to "red") + [JsonConstructor] + public Dog(Option breed = default, Option color = default) : base(color) + { + BreedOption = breed; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string ClassName { get; } = "Dog"; + + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + + /// + /// Gets or Sets Breed + /// + [JsonPropertyName("breed")] + public string Breed { get { return this.BreedOption; } set { this.BreedOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class DogJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option breed = default; + Option color = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); + + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(breed, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, dog, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + { + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + + writer.WriteString("className", dog.ClassName); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs new file mode 100644 index 000000000000..13fe9ec2c1a5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -0,0 +1,268 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Drawing + /// + public partial class Drawing : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// mainShape + /// nullableShape + /// shapeOrNull + /// shapes + [JsonConstructor] + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option> shapes = default) + { + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + + /// + /// Gets or Sets MainShape + /// + [JsonPropertyName("mainShape")] + public Shape MainShape { get { return this.MainShapeOption; } set { this.MainShapeOption = new Option(value); } } + + /// + /// Used to track the state of NullableShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } + + /// + /// Gets or Sets NullableShape + /// + [JsonPropertyName("nullableShape")] + public NullableShape NullableShape { get { return this.NullableShapeOption; } set { this.NullableShapeOption = new Option(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } + + /// + /// Gets or Sets ShapeOrNull + /// + [JsonPropertyName("shapeOrNull")] + public ShapeOrNull ShapeOrNull { get { return this.ShapeOrNullOption; } set { this.ShapeOrNullOption = new Option(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List Shapes { get { return this.ShapesOption; } set { this.ShapesOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Drawing {\n"); + sb.Append(" MainShape: ").Append(MainShape).Append("\n"); + sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); + sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DrawingJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option> shapes = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "mainShape": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "nullableShape": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapeOrNull": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); + + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, drawing, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + { + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs new file mode 100644 index 000000000000..ca521c70857f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -0,0 +1,208 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EnumArrays + /// + public partial class EnumArrays : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayEnum + /// justSymbol + [JsonConstructor] + public EnumArrays(Option> arrayEnum = default, Option justSymbol = default) + { + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + + /// + /// Gets or Sets JustSymbol + /// + [JsonPropertyName("just_symbol")] + public EnumArraysJustSymbol? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new Option(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayEnumOption { get; private set; } + + /// + /// Gets or Sets ArrayEnum + /// + [JsonPropertyName("array_enum")] + public List ArrayEnum { get { return this.ArrayEnumOption; } set { this.ArrayEnumOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EnumArrays {\n"); + sb.Append(" ArrayEnum: ").Append(ArrayEnum).Append("\n"); + sb.Append(" JustSymbol: ").Append(JustSymbol).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EnumArraysJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayEnum = default; + Option justSymbol = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_enum": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayEnum = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "just_symbol": + string justSymbolRawValue = utf8JsonReader.GetString(); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArraysJustSymbolValueConverter.FromStringOrDefault(justSymbolRawValue)); + break; + default: + break; + } + } + } + + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); + + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); + + return new EnumArrays(arrayEnum, justSymbol); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, enumArrays, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + { + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); + + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + if (enumArrays.JustSymbolOption.IsSet) + { + var justSymbolRawValue = EnumArraysJustSymbolValueConverter.ToJsonValue(enumArrays.JustSymbol.Value); + writer.WriteString("just_symbol", justSymbolRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs new file mode 100644 index 000000000000..c620b7197c40 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines EnumArrays_array_enum_inner + /// + public enum EnumArraysArrayEnumInner + { + /// + /// Enum Fish for value: fish + /// + Fish = 1, + + /// + /// Enum Crab for value: crab + /// + Crab = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumArraysArrayEnumInnerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumArraysArrayEnumInner FromString(string value) + { + if (value.Equals("fish")) + return EnumArraysArrayEnumInner.Fish; + + if (value.Equals("crab")) + return EnumArraysArrayEnumInner.Crab; + + throw new NotImplementedException($"Could not convert value to type EnumArraysArrayEnumInner: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumArraysArrayEnumInner? FromStringOrDefault(string value) + { + if (value.Equals("fish")) + return EnumArraysArrayEnumInner.Fish; + + if (value.Equals("crab")) + return EnumArraysArrayEnumInner.Crab; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(EnumArraysArrayEnumInner value) + { + if (value == EnumArraysArrayEnumInner.Fish) + return "fish"; + + if (value == EnumArraysArrayEnumInner.Crab) + return "crab"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumArraysArrayEnumInnerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumArraysArrayEnumInner Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumArraysArrayEnumInner? result = rawValue == null + ? null + : EnumArraysArrayEnumInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumArraysArrayEnumInner to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArraysArrayEnumInner enumArraysArrayEnumInner, JsonSerializerOptions options) + { + writer.WriteStringValue(enumArraysArrayEnumInner.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumArraysArrayEnumInnerNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumArraysArrayEnumInner from the Json object + /// + /// + /// + /// + /// + public override EnumArraysArrayEnumInner? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumArraysArrayEnumInner? result = rawValue == null + ? null + : EnumArraysArrayEnumInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArraysArrayEnumInner? enumArraysArrayEnumInner, JsonSerializerOptions options) + { + writer.WriteStringValue(enumArraysArrayEnumInner?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs new file mode 100644 index 000000000000..4a414d11d0db --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines EnumArrays_just_symbol + /// + public enum EnumArraysJustSymbol + { + /// + /// Enum GreaterThanOrEqualTo for value: >= + /// + GreaterThanOrEqualTo = 1, + + /// + /// Enum Dollar for value: $ + /// + Dollar = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumArraysJustSymbolValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumArraysJustSymbol FromString(string value) + { + if (value.Equals(">=")) + return EnumArraysJustSymbol.GreaterThanOrEqualTo; + + if (value.Equals("$")) + return EnumArraysJustSymbol.Dollar; + + throw new NotImplementedException($"Could not convert value to type EnumArraysJustSymbol: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumArraysJustSymbol? FromStringOrDefault(string value) + { + if (value.Equals(">=")) + return EnumArraysJustSymbol.GreaterThanOrEqualTo; + + if (value.Equals("$")) + return EnumArraysJustSymbol.Dollar; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(EnumArraysJustSymbol value) + { + if (value == EnumArraysJustSymbol.GreaterThanOrEqualTo) + return ">="; + + if (value == EnumArraysJustSymbol.Dollar) + return "$"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumArraysJustSymbolJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumArraysJustSymbol Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumArraysJustSymbol? result = rawValue == null + ? null + : EnumArraysJustSymbolValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumArraysJustSymbol to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArraysJustSymbol enumArraysJustSymbol, JsonSerializerOptions options) + { + writer.WriteStringValue(enumArraysJustSymbol.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumArraysJustSymbolNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumArraysJustSymbol from the Json object + /// + /// + /// + /// + /// + public override EnumArraysJustSymbol? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumArraysJustSymbol? result = rawValue == null + ? null + : EnumArraysJustSymbolValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArraysJustSymbol? enumArraysJustSymbol, JsonSerializerOptions options) + { + writer.WriteStringValue(enumArraysJustSymbol?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumClass.cs new file mode 100644 index 000000000000..b1aff0adf0d8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumClass.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines EnumClass + /// + public enum EnumClass + { + /// + /// Enum Abc for value: _abc + /// + Abc = 1, + + /// + /// Enum Efg for value: -efg + /// + Efg = 2, + + /// + /// Enum Xyz for value: (xyz) + /// + Xyz = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumClassValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumClass FromString(string value) + { + if (value.Equals("_abc")) + return EnumClass.Abc; + + if (value.Equals("-efg")) + return EnumClass.Efg; + + if (value.Equals("(xyz)")) + return EnumClass.Xyz; + + throw new NotImplementedException($"Could not convert value to type EnumClass: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumClass? FromStringOrDefault(string value) + { + if (value.Equals("_abc")) + return EnumClass.Abc; + + if (value.Equals("-efg")) + return EnumClass.Efg; + + if (value.Equals("(xyz)")) + return EnumClass.Xyz; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(EnumClass value) + { + if (value == EnumClass.Abc) + return "_abc"; + + if (value == EnumClass.Efg) + return "-efg"; + + if (value == EnumClass.Xyz) + return "(xyz)"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumClassJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumClass Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumClass? result = rawValue == null + ? null + : EnumClassValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumClass to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumClass enumClass, JsonSerializerOptions options) + { + writer.WriteStringValue(enumClass.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumClassNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumClass from the Json object + /// + /// + /// + /// + /// + public override EnumClass? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumClass? result = rawValue == null + ? null + : EnumClassValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumClass? enumClass, JsonSerializerOptions options) + { + writer.WriteStringValue(enumClass?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs new file mode 100644 index 000000000000..250e6b8c9dba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs @@ -0,0 +1,410 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EnumTest + /// + public partial class EnumTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// enumStringRequired + /// enumInteger + /// enumIntegerOnly + /// enumNumber + /// enumString + /// outerEnum + /// outerEnumDefaultValue + /// outerEnumInteger + /// outerEnumIntegerDefaultValue + [JsonConstructor] + public EnumTest(EnumTestEnumString enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) + { + EnumStringRequired = enumStringRequired; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets EnumStringRequired + /// + [JsonPropertyName("enum_string_required")] + public EnumTestEnumString EnumStringRequired { get; set; } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumTestEnumInteger? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumTestEnumIntegerOnly? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new Option(value); } } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public TestEnumParametersEnumQueryDoubleParameter? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new Option(value); } } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumTestEnumString? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } + + /// + /// Gets or Sets OuterEnum + /// + [JsonPropertyName("outerEnum")] + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); + sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); + sb.Append(" EnumString: ").Append(EnumString).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); + sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); + sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); + sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EnumTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "enum_string_required": + string enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTestEnumStringValueConverter.FromStringOrDefault(enumStringRequiredRawValue)); + break; + case "enum_integer": + string enumIntegerRawValue = utf8JsonReader.GetString(); + if (enumIntegerRawValue != null) + enumInteger = new Option(EnumTestEnumIntegerValueConverter.FromStringOrDefault(enumIntegerRawValue)); + break; + case "enum_integer_only": + string enumIntegerOnlyRawValue = utf8JsonReader.GetString(); + if (enumIntegerOnlyRawValue != null) + enumIntegerOnly = new Option(EnumTestEnumIntegerOnlyValueConverter.FromStringOrDefault(enumIntegerOnlyRawValue)); + break; + case "enum_number": + string enumNumberRawValue = utf8JsonReader.GetString(); + if (enumNumberRawValue != null) + enumNumber = new Option(TestEnumParametersEnumQueryDoubleParameterValueConverter.FromStringOrDefault(enumNumberRawValue)); + break; + case "enum_string": + string enumStringRawValue = utf8JsonReader.GetString(); + if (enumStringRawValue != null) + enumString = new Option(EnumTestEnumStringValueConverter.FromStringOrDefault(enumStringRawValue)); + break; + case "outerEnum": + string outerEnumRawValue = utf8JsonReader.GetString(); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); + break; + default: + break; + } + } + } + + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); + + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); + + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); + + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); + + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); + + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); + + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); + + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); + + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value.Value, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, enumTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + { + var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired); + writer.WriteString("enum_string_required", enumStringRequiredRawValue); + + if (enumTest.EnumIntegerOption.IsSet) + { + var enumIntegerRawValue = EnumTestEnumIntegerValueConverter.ToJsonValue(enumTest.EnumInteger.Value); + writer.WriteNumber("enum_integer", enumIntegerRawValue); + } + if (enumTest.EnumIntegerOnlyOption.IsSet) + { + var enumIntegerOnlyRawValue = EnumTestEnumIntegerOnlyValueConverter.ToJsonValue(enumTest.EnumIntegerOnly.Value); + writer.WriteNumber("enum_integer_only", enumIntegerOnlyRawValue); + } + if (enumTest.EnumNumberOption.IsSet) + { + var enumNumberRawValue = TestEnumParametersEnumQueryDoubleParameterValueConverter.ToJsonValue(enumTest.EnumNumber.Value); + writer.WriteNumber("enum_number", enumNumberRawValue); + } + if (enumTest.EnumStringOption.IsSet) + { + var enumStringRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumString.Value); + writer.WriteString("enum_string", enumStringRawValue); + } + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value.Value); + writer.WriteString("outerEnum", outerEnumRawValue); + } + else + writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumInteger.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumInteger.cs new file mode 100644 index 000000000000..3a1302bf271e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumInteger.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines Enum_Test_enum_integer + /// + public enum EnumTestEnumInteger + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumTestEnumIntegerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumInteger FromString(string value) + { + if (value.Equals((1).ToString())) + return EnumTestEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumTestEnumInteger.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumTestEnumInteger: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumInteger? FromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumTestEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumTestEnumInteger.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(EnumTestEnumInteger value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumTestEnumIntegerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumInteger? result = rawValue == null + ? null + : EnumTestEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumTestEnumInteger to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumInteger enumTestEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumInteger.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumTestEnumIntegerNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumTestEnumInteger from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumInteger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumInteger? result = rawValue == null + ? null + : EnumTestEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumInteger? enumTestEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumInteger?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumIntegerOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumIntegerOnly.cs new file mode 100644 index 000000000000..cd0add6cf3ce --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumIntegerOnly.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines Enum_Test_enum_integer_only + /// + public enum EnumTestEnumIntegerOnly + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumTestEnumIntegerOnlyValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumIntegerOnly FromString(string value) + { + if (value.Equals((2).ToString())) + return EnumTestEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumTestEnumIntegerOnly.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumTestEnumIntegerOnly: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumIntegerOnly? FromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumTestEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumTestEnumIntegerOnly.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(EnumTestEnumIntegerOnly value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumTestEnumIntegerOnlyJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumIntegerOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumIntegerOnly? result = rawValue == null + ? null + : EnumTestEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumTestEnumIntegerOnly to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumIntegerOnly enumTestEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumIntegerOnly.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumTestEnumIntegerOnlyNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumTestEnumIntegerOnly from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumIntegerOnly? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumIntegerOnly? result = rawValue == null + ? null + : EnumTestEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumIntegerOnly? enumTestEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumIntegerOnly?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumString.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumString.cs new file mode 100644 index 000000000000..adad28355b70 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EnumTestEnumString.cs @@ -0,0 +1,258 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines Enum_Test_enum_string + /// + public enum EnumTestEnumString + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumTestEnumStringValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumString FromString(string value) + { + if (value.Equals("UPPER")) + return EnumTestEnumString.UPPER; + + if (value.Equals("lower")) + return EnumTestEnumString.Lower; + + if (value.Equals("")) + return EnumTestEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return EnumTestEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumTestEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumTestEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumTestEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumTestEnumString.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumTestEnumString: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumTestEnumString? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumTestEnumString.UPPER; + + if (value.Equals("lower")) + return EnumTestEnumString.Lower; + + if (value.Equals("")) + return EnumTestEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return EnumTestEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumTestEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumTestEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumTestEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumTestEnumString.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(EnumTestEnumString value) + { + if (value == EnumTestEnumString.UPPER) + return "UPPER"; + + if (value == EnumTestEnumString.Lower) + return "lower"; + + if (value == EnumTestEnumString.Empty) + return ""; + + if (value == EnumTestEnumString.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumTestEnumString.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumTestEnumString.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumTestEnumString.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumTestEnumString.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumTestEnumStringJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumString? result = rawValue == null + ? null + : EnumTestEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumTestEnumString to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumString enumTestEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumString.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumTestEnumStringNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumTestEnumString from the Json object + /// + /// + /// + /// + /// + public override EnumTestEnumString? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumTestEnumString? result = rawValue == null + ? null + : EnumTestEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTestEnumString? enumTestEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(enumTestEnumString?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs new file mode 100644 index 000000000000..b84f89b531dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EquilateralTriangle + /// + public partial class EquilateralTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public EquilateralTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EquilateralTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EquilateralTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EquilateralTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + + writer.WriteString("triangleType", equilateralTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs new file mode 100644 index 000000000000..95403fdaf96d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/File.cs @@ -0,0 +1,175 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Must be named `File` for test. + /// + public partial class File : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Test capitalization + [JsonConstructor] + public File(Option sourceURI = default) + { + SourceURIOption = sourceURI; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + + /// + /// Test capitalization + /// + /// Test capitalization + [JsonPropertyName("sourceURI")] + public string SourceURI { get { return this.SourceURIOption; } set { this.SourceURIOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class File {\n"); + sb.Append(" SourceURI: ").Append(SourceURI).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FileJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option sourceURI = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "sourceURI": + sourceURI = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); + + return new File(sourceURI); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, file, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + { + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs new file mode 100644 index 000000000000..4906accc7ed4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -0,0 +1,210 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FileSchemaTestClass + /// + public partial class FileSchemaTestClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// file + /// files + [JsonConstructor] + public FileSchemaTestClass(Option file = default, Option> files = default) + { + FileOption = file; + FilesOption = files; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + + /// + /// Gets or Sets File + /// + [JsonPropertyName("file")] + public File File { get { return this.FileOption; } set { this.FileOption = new Option(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> FilesOption { get; private set; } + + /// + /// Gets or Sets Files + /// + [JsonPropertyName("files")] + public List Files { get { return this.FilesOption; } set { this.FilesOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FileSchemaTestClass {\n"); + sb.Append(" File: ").Append(File).Append("\n"); + sb.Append(" Files: ").Append(Files).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FileSchemaTestClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option file = default; + Option> files = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "file": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "files": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + files = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); + + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); + + return new FileSchemaTestClass(file, files); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + { + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FindPetsByStatusStatusParameterInner.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FindPetsByStatusStatusParameterInner.cs new file mode 100644 index 000000000000..da357d93dd28 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FindPetsByStatusStatusParameterInner.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines findPetsByStatus_status_parameter_inner + /// + public enum FindPetsByStatusStatusParameterInner + { + /// + /// Enum Available for value: available + /// + Available = 1, + + /// + /// Enum Pending for value: pending + /// + Pending = 2, + + /// + /// Enum Sold for value: sold + /// + Sold = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class FindPetsByStatusStatusParameterInnerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static FindPetsByStatusStatusParameterInner FromString(string value) + { + if (value.Equals("available")) + return FindPetsByStatusStatusParameterInner.Available; + + if (value.Equals("pending")) + return FindPetsByStatusStatusParameterInner.Pending; + + if (value.Equals("sold")) + return FindPetsByStatusStatusParameterInner.Sold; + + throw new NotImplementedException($"Could not convert value to type FindPetsByStatusStatusParameterInner: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static FindPetsByStatusStatusParameterInner? FromStringOrDefault(string value) + { + if (value.Equals("available")) + return FindPetsByStatusStatusParameterInner.Available; + + if (value.Equals("pending")) + return FindPetsByStatusStatusParameterInner.Pending; + + if (value.Equals("sold")) + return FindPetsByStatusStatusParameterInner.Sold; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(FindPetsByStatusStatusParameterInner value) + { + if (value == FindPetsByStatusStatusParameterInner.Available) + return "available"; + + if (value == FindPetsByStatusStatusParameterInner.Pending) + return "pending"; + + if (value == FindPetsByStatusStatusParameterInner.Sold) + return "sold"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class FindPetsByStatusStatusParameterInnerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override FindPetsByStatusStatusParameterInner Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + FindPetsByStatusStatusParameterInner? result = rawValue == null + ? null + : FindPetsByStatusStatusParameterInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the FindPetsByStatusStatusParameterInner to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FindPetsByStatusStatusParameterInner findPetsByStatusStatusParameterInner, JsonSerializerOptions options) + { + writer.WriteStringValue(findPetsByStatusStatusParameterInner.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class FindPetsByStatusStatusParameterInnerNullableJsonConverter : JsonConverter + { + /// + /// Returns a FindPetsByStatusStatusParameterInner from the Json object + /// + /// + /// + /// + /// + public override FindPetsByStatusStatusParameterInner? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + FindPetsByStatusStatusParameterInner? result = rawValue == null + ? null + : FindPetsByStatusStatusParameterInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FindPetsByStatusStatusParameterInner? findPetsByStatusStatusParameterInner, JsonSerializerOptions options) + { + writer.WriteStringValue(findPetsByStatusStatusParameterInner?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs new file mode 100644 index 000000000000..a78d7a84f34f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Foo.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Foo + /// + public partial class Foo : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar (default to "bar") + [JsonConstructor] + public Foo(Option bar = default) + { + BarOption = bar; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } set { this.BarOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Foo {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FooJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); + + return new Foo(bar); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, foo, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + { + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs new file mode 100644 index 000000000000..4564148c4d9c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FooGetDefaultResponse + /// + public partial class FooGetDefaultResponse : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// string + [JsonConstructor] + public FooGetDefaultResponse(Option @string = default) + { + StringOption = @string; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + [JsonPropertyName("string")] + public Foo String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FooGetDefaultResponse {\n"); + sb.Append(" String: ").Append(String).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FooGetDefaultResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); + + return new FooGetDefaultResponse(varString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + { + if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.StringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.String, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs new file mode 100644 index 000000000000..09b13bde9f7a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs @@ -0,0 +1,798 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FormatTest + /// + public partial class FormatTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// byte + /// date + /// number + /// password + /// binary + /// dateTime + /// decimal + /// double + /// float + /// int32 + /// int64 + /// integer + /// None + /// A string that is a 10 digit number. Can have leading zeros. + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + /// string + /// unsignedInteger + /// unsignedLong + /// uuid + [JsonConstructor] + public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int64 = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default) + { + Byte = @byte; + Date = date; + Number = number; + Password = password; + BinaryOption = binary; + DateTimeOption = dateTime; + DecimalOption = @decimal; + DoubleOption = @double; + FloatOption = @float; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + StringOption = @string; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Byte + /// + [JsonPropertyName("byte")] + public byte[] Byte { get; set; } + + /// + /// Gets or Sets Date + /// + /// Sun Feb 02 00:00:00 UTC 2020 + [JsonPropertyName("date")] + public DateTime Date { get; set; } + + /// + /// Gets or Sets Number + /// + [JsonPropertyName("number")] + public decimal Number { get; set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get; set; } + + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream Binary { get { return this.BinaryOption; } set { this.BinaryOption = new Option(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this.DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + [JsonPropertyName("decimal")] + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of Double + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DoubleOption { get; private set; } + + /// + /// Gets or Sets Double + /// + [JsonPropertyName("double")] + public double? Double { get { return this.DoubleOption; } set { this.DoubleOption = new Option(value); } } + + /// + /// Used to track the state of Float + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FloatOption { get; private set; } + + /// + /// Gets or Sets Float + /// + [JsonPropertyName("float")] + public float? Float { get { return this.FloatOption; } set { this.FloatOption = new Option(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this.Int32Option; } set { this.Int32Option = new Option(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this.Int64Option; } set { this.Int64Option = new Option(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this.IntegerOption; } set { this.IntegerOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + + /// + /// None + /// + /// None + [JsonPropertyName("pattern_with_backslash")] + public string PatternWithBackslash { get { return this.PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } + + /// + /// A string that is a 10 digit number. Can have leading zeros. + /// + /// A string that is a 10 digit number. Can have leading zeros. + [JsonPropertyName("pattern_with_digits")] + public string PatternWithDigits { get { return this.PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } + + /// + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + /// + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + [JsonPropertyName("pattern_with_digits_and_delimiter")] + public string PatternWithDigitsAndDelimiter { get { return this.PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new Option(value); } } + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + [JsonPropertyName("string")] + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } + + /// + /// Gets or Sets UnsignedInteger + /// + [JsonPropertyName("unsigned_integer")] + public uint? UnsignedInteger { get { return this.UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } + + /// + /// Gets or Sets UnsignedLong + /// + [JsonPropertyName("unsigned_long")] + public ulong? UnsignedLong { get { return this.UnsignedLongOption; } set { this.UnsignedLongOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FormatTest {\n"); + sb.Append(" Byte: ").Append(Byte).Append("\n"); + sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Decimal: ").Append(Decimal).Append("\n"); + sb.Append(" Double: ").Append(Double).Append("\n"); + sb.Append(" Float: ").Append(Float).Append("\n"); + sb.Append(" Int32: ").Append(Int32).Append("\n"); + sb.Append(" Int64: ").Append(Int64).Append("\n"); + sb.Append(" Integer: ").Append(Integer).Append("\n"); + sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); + sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); + sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); + sb.Append(" String: ").Append(String).Append("\n"); + sb.Append(" UnsignedInteger: ").Append(UnsignedInteger).Append("\n"); + sb.Append(" UnsignedLong: ").Append(UnsignedLong).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + // Number (decimal) maximum + if (this.Number > (decimal)543.2) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value less than or equal to 543.2.", new [] { "Number" }); + } + + // Number (decimal) minimum + if (this.Number < (decimal)32.1) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" }); + } + + // Password (string) maxLength + if (this.Password != null && this.Password.Length > 64) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be less than 64.", new [] { "Password" }); + } + + // Password (string) minLength + if (this.Password != null && this.Password.Length < 10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); + } + + // Double (double) maximum + if (this.DoubleOption.IsSet && this.DoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value less than or equal to 123.4.", new [] { "Double" }); + } + + // Double (double) minimum + if (this.DoubleOption.IsSet && this.DoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value greater than or equal to 67.8.", new [] { "Double" }); + } + + // Float (float) maximum + if (this.FloatOption.IsSet && this.FloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value less than or equal to 987.6.", new [] { "Float" }); + } + + // Float (float) minimum + if (this.FloatOption.IsSet && this.FloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value greater than or equal to 54.3.", new [] { "Float" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { + // PatternWithBackslash (string) pattern + Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); + } + } + + if (this.PatternWithDigitsOption.Value != null) { + // PatternWithDigits (string) pattern + Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); + } + } + + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { + // PatternWithDigitsAndDelimiter (string) pattern + Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); + } + } + + if (this.StringOption.Value != null) { + // String (string) pattern + Regex regexString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.StringOption.Value != null &&!regexString.Match(this.StringOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for String, must match a pattern of " + regexString, new [] { "String" }); + } + } + + // UnsignedInteger (uint) maximum + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); + } + + // UnsignedInteger (uint) minimum + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); + } + + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FormatTestJsonConverter : JsonConverter + { + /// + /// The format to use to serialize Date + /// + public static string DateFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize DateTime + /// + public static string DateTimeFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + Option binary = default; + Option dateTime = default; + Option varDecimal = default; + Option varDouble = default; + Option varFloat = default; + Option int32 = default; + Option int64 = default; + Option integer = default; + Option patternWithBackslash = default; + Option patternWithDigits = default; + Option patternWithDigitsAndDelimiter = default; + Option varString = default; + Option unsignedInteger = default; + Option unsignedLong = default; + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "byte": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "date": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + number = new Option(utf8JsonReader.GetDecimal()); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); + break; + case "pattern_with_backslash": + patternWithBackslash = new Option(utf8JsonReader.GetString()); + break; + case "pattern_with_digits": + patternWithDigits = new Option(utf8JsonReader.GetString()); + break; + case "pattern_with_digits_and_delimiter": + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()); + break; + case "string": + varString = new Option(utf8JsonReader.GetString()); + break; + case "unsigned_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); + break; + case "unsigned_long": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + unsignedLong = new Option(utf8JsonReader.GetUInt64()); + break; + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); + + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); + + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); + + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); + + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); + + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); + + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); + + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); + + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); + + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); + + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); + + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); + + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); + + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); + + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); + + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); + + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); + + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest."); + + return new FormatTest(varByte.Value, date.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, formatTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + { + if (formatTest.Byte == null) + throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.StringOption.IsSet && formatTest.String == null) + throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest."); + + writer.WritePropertyName("byte"); + JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions); + writer.WriteString("date", formatTest.Date.ToString(DateFormat)); + + writer.WriteNumber("number", formatTest.Number); + + writer.WriteString("password", formatTest.Password); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (formatTest.DecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions); + } + if (formatTest.DoubleOption.IsSet) + writer.WriteNumber("double", formatTest.DoubleOption.Value.Value); + + if (formatTest.FloatOption.IsSet) + writer.WriteNumber("float", formatTest.FloatOption.Value.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.StringOption.IsSet) + writer.WriteString("string", formatTest.String); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs new file mode 100644 index 000000000000..8e650b7b07cc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Fruit.cs @@ -0,0 +1,218 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Fruit + /// + public partial class Fruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Apple apple, Option color = default) + { + Apple = apple; + ColorOption = color; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Banana banana, Option color = default) + { + Banana = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get; set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get; set; } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Fruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs new file mode 100644 index 000000000000..f5dd6d56278f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FruitReq + /// + public partial class FruitReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public FruitReq(AppleReq appleReq) + { + AppleReq = appleReq; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public FruitReq(BananaReq bananaReq) + { + BananaReq = bananaReq; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets AppleReq + /// + public AppleReq AppleReq { get; set; } + + /// + /// Gets or Sets BananaReq + /// + public BananaReq BananaReq { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FruitReq {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FruitReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + AppleReq appleReq = default; + BananaReq bananaReq = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderAppleReq = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderAppleReq, jsonSerializerOptions, out appleReq); + + Utf8JsonReader utf8JsonReaderBananaReq = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBananaReq, jsonSerializerOptions, out bananaReq); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (appleReq != null) + return new FruitReq(appleReq); + + if (bananaReq != null) + return new FruitReq(bananaReq); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fruitReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs new file mode 100644 index 000000000000..14d47fa32935 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs @@ -0,0 +1,235 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// GmFruit + /// + public partial class GmFruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// color + public GmFruit(Option apple, Option banana, Option color = default) + { + AppleOption = apple; + BananaOption = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new Option(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class GmFruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class GmFruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); + + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) + { + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + } + + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) + { + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, gmFruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + { + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs new file mode 100644 index 000000000000..86246ae54570 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -0,0 +1,192 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// GrandparentAnimal + /// + public partial class GrandparentAnimal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public GrandparentAnimal() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class GrandparentAnimal {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class GrandparentAnimalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option petType = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type"); + + if (discriminator != null && discriminator.Equals("ChildCat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + if (discriminator != null && discriminator.Equals("ParentPet")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "pet_type": + petType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + { + if (grandparentAnimal is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + + if (grandparentAnimal is ParentPet parentPet){ + JsonSerializer.Serialize(writer, parentPet, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("pet_type", grandparentAnimal.PetType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs new file mode 100644 index 000000000000..88c5d4274eab --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -0,0 +1,244 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// HasOnlyReadOnly + /// + public partial class HasOnlyReadOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar + /// foo + [JsonConstructor] + internal HasOnlyReadOnly(Option bar = default, Option foo = default) + { + BarOption = bar; + FooOption = foo; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } + + /// + /// Gets or Sets Foo + /// + [JsonPropertyName("foo")] + public string Foo { get { return this.FooOption; } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class HasOnlyReadOnly {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Foo: ").Append(Foo).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as HasOnlyReadOnly).AreEqual; + } + + /// + /// Returns true if HasOnlyReadOnly instances are equal + /// + /// Instance of HasOnlyReadOnly to be compared + /// Boolean + public bool Equals(HasOnlyReadOnly input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class HasOnlyReadOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + Option foo = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + case "foo": + foo = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); + + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); + + return new HasOnlyReadOnly(bar, foo); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs new file mode 100644 index 000000000000..4f9c831edc26 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -0,0 +1,171 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + /// + public partial class HealthCheckResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// nullableMessage + [JsonConstructor] + public HealthCheckResult(Option nullableMessage = default) + { + NullableMessageOption = nullableMessage; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + + /// + /// Gets or Sets NullableMessage + /// + [JsonPropertyName("NullableMessage")] + public string NullableMessage { get { return this.NullableMessageOption; } set { this.NullableMessageOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class HealthCheckResult {\n"); + sb.Append(" NullableMessage: ").Append(NullableMessage).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class HealthCheckResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override HealthCheckResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option nullableMessage = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "NullableMessage": + nullableMessage = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + return new HealthCheckResult(nullableMessage); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + { + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs new file mode 100644 index 000000000000..384e48f3a155 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -0,0 +1,186 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// IsoscelesTriangle + /// + public partial class IsoscelesTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public IsoscelesTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class IsoscelesTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class IsoscelesTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override IsoscelesTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs new file mode 100644 index 000000000000..07fcd017a689 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/List.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// List + /// + public partial class List : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// var123List + [JsonConstructor] + public List(Option var123List = default) + { + Var123ListOption = var123List; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + + /// + /// Gets or Sets Var123List + /// + [JsonPropertyName("123-list")] + public string Var123List { get { return this.Var123ListOption; } set { this.Var123ListOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class List {\n"); + sb.Append(" Var123List: ").Append(Var123List).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ListJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option var123List = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "123-list": + var123List = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); + + return new List(var123List); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, list, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + { + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs new file mode 100644 index 000000000000..c5fc2e2e77c1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -0,0 +1,203 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// LiteralStringClass + /// + public partial class LiteralStringClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// escapedLiteralString (default to "C:\\Users\\username") + /// unescapedLiteralString (default to "C:\Users\username") + [JsonConstructor] + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) + { + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + + /// + /// Gets or Sets EscapedLiteralString + /// + [JsonPropertyName("escapedLiteralString")] + public string EscapedLiteralString { get { return this.EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new Option(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } + + /// + /// Gets or Sets UnescapedLiteralString + /// + [JsonPropertyName("unescapedLiteralString")] + public string UnescapedLiteralString { get { return this.UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class LiteralStringClass {\n"); + sb.Append(" EscapedLiteralString: ").Append(EscapedLiteralString).Append("\n"); + sb.Append(" UnescapedLiteralString: ").Append(UnescapedLiteralString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class LiteralStringClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option escapedLiteralString = default; + Option unescapedLiteralString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "escapedLiteralString": + escapedLiteralString = new Option(utf8JsonReader.GetString()); + break; + case "unescapedLiteralString": + unescapedLiteralString = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); + + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); + + return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, literalStringClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + { + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs new file mode 100644 index 000000000000..1be5661d9936 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs @@ -0,0 +1,266 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mammal + /// + public partial class Mammal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Whale whale) + { + Whale = whale; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Zebra zebra) + { + Zebra = zebra; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Pig pig) + { + Pig = pig; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Whale + /// + public Whale Whale { get; set; } + + /// + /// Gets or Sets Zebra + /// + public Zebra Zebra { get; set; } + + /// + /// Gets or Sets Pig + /// + public Pig Pig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Mammal {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MammalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + Pig pig = null; + Whale whale = null; + Zebra zebra = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("className")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Pig")) + { + Utf8JsonReader utf8JsonReaderPig = utf8JsonReader; + pig = JsonSerializer.Deserialize(ref utf8JsonReaderPig, jsonSerializerOptions); + } + if (discriminator.Equals("whale")) + { + Utf8JsonReader utf8JsonReaderWhale = utf8JsonReader; + whale = JsonSerializer.Deserialize(ref utf8JsonReaderWhale, jsonSerializerOptions); + } + if (discriminator.Equals("zebra")) + { + Utf8JsonReader utf8JsonReaderZebra = utf8JsonReader; + zebra = JsonSerializer.Deserialize(ref utf8JsonReaderZebra, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); + + if (pig != null) + return new Mammal(pig); + + if (whale != null) + return new Mammal(whale); + + if (zebra != null) + return new Mammal(zebra); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mammal.Whale != null) { + WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); + } + + if (mammal.Zebra != null) { + ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); + } + + if (mammal.Pig != null) { + PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); + } + + WriteProperties(writer, mammal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs new file mode 100644 index 000000000000..6f2e55bcffda --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTest.cs @@ -0,0 +1,274 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MapTest + /// + public partial class MapTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// directMap + /// indirectMap + /// mapMapOfString + /// mapOfEnumString + [JsonConstructor] + public MapTest(Option> directMap = default, Option> indirectMap = default, Option>> mapMapOfString = default, Option> mapOfEnumString = default) + { + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> DirectMapOption { get; private set; } + + /// + /// Gets or Sets DirectMap + /// + [JsonPropertyName("direct_map")] + public Dictionary DirectMap { get { return this.DirectMapOption; } set { this.DirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> IndirectMapOption { get; private set; } + + /// + /// Gets or Sets IndirectMap + /// + [JsonPropertyName("indirect_map")] + public Dictionary IndirectMap { get { return this.IndirectMapOption; } set { this.IndirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapMapOfStringOption { get; private set; } + + /// + /// Gets or Sets MapMapOfString + /// + [JsonPropertyName("map_map_of_string")] + public Dictionary> MapMapOfString { get { return this.MapMapOfStringOption; } set { this.MapMapOfStringOption = new Option>>(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOfEnumStringOption { get; private set; } + + /// + /// Gets or Sets MapOfEnumString + /// + [JsonPropertyName("map_of_enum_string")] + public Dictionary MapOfEnumString { get { return this.MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MapTest {\n"); + sb.Append(" DirectMap: ").Append(DirectMap).Append("\n"); + sb.Append(" IndirectMap: ").Append(IndirectMap).Append("\n"); + sb.Append(" MapMapOfString: ").Append(MapMapOfString).Append("\n"); + sb.Append(" MapOfEnumString: ").Append(MapOfEnumString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MapTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> directMap = default; + Option> indirectMap = default; + Option>> mapMapOfString = default; + Option> mapOfEnumString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "direct_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + directMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "indirect_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + indirectMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_map_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapMapOfString = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_of_enum_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapOfEnumString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); + + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); + + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); + + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); + + return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mapTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + { + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs new file mode 100644 index 000000000000..441ea5dcb7da --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MapTest_map_of_enum_string_value + /// + public enum MapTestMapOfEnumStringValue + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class MapTestMapOfEnumStringValueValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static MapTestMapOfEnumStringValue FromString(string value) + { + if (value.Equals("UPPER")) + return MapTestMapOfEnumStringValue.UPPER; + + if (value.Equals("lower")) + return MapTestMapOfEnumStringValue.Lower; + + throw new NotImplementedException($"Could not convert value to type MapTestMapOfEnumStringValue: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static MapTestMapOfEnumStringValue? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return MapTestMapOfEnumStringValue.UPPER; + + if (value.Equals("lower")) + return MapTestMapOfEnumStringValue.Lower; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(MapTestMapOfEnumStringValue value) + { + if (value == MapTestMapOfEnumStringValue.UPPER) + return "UPPER"; + + if (value == MapTestMapOfEnumStringValue.Lower) + return "lower"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class MapTestMapOfEnumStringValueJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override MapTestMapOfEnumStringValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + MapTestMapOfEnumStringValue? result = rawValue == null + ? null + : MapTestMapOfEnumStringValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the MapTestMapOfEnumStringValue to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MapTestMapOfEnumStringValue mapTestMapOfEnumStringValue, JsonSerializerOptions options) + { + writer.WriteStringValue(mapTestMapOfEnumStringValue.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class MapTestMapOfEnumStringValueNullableJsonConverter : JsonConverter + { + /// + /// Returns a MapTestMapOfEnumStringValue from the Json object + /// + /// + /// + /// + /// + public override MapTestMapOfEnumStringValue? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + MapTestMapOfEnumStringValue? result = rawValue == null + ? null + : MapTestMapOfEnumStringValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MapTestMapOfEnumStringValue? mapTestMapOfEnumStringValue, JsonSerializerOptions options) + { + writer.WriteStringValue(mapTestMapOfEnumStringValue?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixLog.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixLog.cs new file mode 100644 index 000000000000..75cdeb1ec5b0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixLog.cs @@ -0,0 +1,1027 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixLog + /// + public partial class MixLog : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// description + /// formulaVersionDate + /// id + /// mixDate + /// totalOverPoors + /// totalRecalculations + /// totalSkips + /// totalUnderPours + /// batchNumber + /// BrandCode is only required for non-color mixes + /// BrandId is only required for color mixes + /// BrandName is only required for color mixes + /// CategoryCode is not used anymore + /// Color is only required for color mixes + /// colorDescription + /// comment + /// commercialProductCode + /// country + /// createdBy + /// createdByFirstName + /// createdByLastName + /// deltaECalculationRepaired + /// deltaECalculationSprayout + /// ownColorVariantNumber + /// primerProductId + /// ProductId is only required for color mixes + /// ProductLineCode is only required for color mixes + /// ProductName is only required for color mixes + /// selectedVersionIndex + /// shopId + /// SomeCode is only required for color mixes + /// totalPrice + [JsonConstructor] + public MixLog(string description, DateTime formulaVersionDate, Guid id, DateTime mixDate, int totalOverPoors, int totalRecalculations, int totalSkips, int totalUnderPours, Option batchNumber = default, Option brandCode = default, Option brandId = default, Option brandName = default, Option categoryCode = default, Option color = default, Option colorDescription = default, Option comment = default, Option commercialProductCode = default, Option country = default, Option createdBy = default, Option createdByFirstName = default, Option createdByLastName = default, Option deltaECalculationRepaired = default, Option deltaECalculationSprayout = default, Option ownColorVariantNumber = default, Option primerProductId = default, Option productId = default, Option productLineCode = default, Option productName = default, Option selectedVersionIndex = default, Option shopId = default, Option someCode = default, Option totalPrice = default) + { + Description = description; + FormulaVersionDate = formulaVersionDate; + Id = id; + MixDate = mixDate; + TotalOverPoors = totalOverPoors; + TotalRecalculations = totalRecalculations; + TotalSkips = totalSkips; + TotalUnderPours = totalUnderPours; + BatchNumberOption = batchNumber; + BrandCodeOption = brandCode; + BrandIdOption = brandId; + BrandNameOption = brandName; + CategoryCodeOption = categoryCode; + ColorOption = color; + ColorDescriptionOption = colorDescription; + CommentOption = comment; + CommercialProductCodeOption = commercialProductCode; + CountryOption = country; + CreatedByOption = createdBy; + CreatedByFirstNameOption = createdByFirstName; + CreatedByLastNameOption = createdByLastName; + DeltaECalculationRepairedOption = deltaECalculationRepaired; + DeltaECalculationSprayoutOption = deltaECalculationSprayout; + OwnColorVariantNumberOption = ownColorVariantNumber; + PrimerProductIdOption = primerProductId; + ProductIdOption = productId; + ProductLineCodeOption = productLineCode; + ProductNameOption = productName; + SelectedVersionIndexOption = selectedVersionIndex; + ShopIdOption = shopId; + SomeCodeOption = someCode; + TotalPriceOption = totalPrice; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Description + /// + [JsonPropertyName("description")] + public string Description { get; set; } + + /// + /// Gets or Sets FormulaVersionDate + /// + [JsonPropertyName("formulaVersionDate")] + public DateTime FormulaVersionDate { get; set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public Guid Id { get; set; } + + /// + /// Gets or Sets MixDate + /// + [JsonPropertyName("mixDate")] + public DateTime MixDate { get; set; } + + /// + /// Gets or Sets TotalOverPoors + /// + [JsonPropertyName("totalOverPoors")] + public int TotalOverPoors { get; set; } + + /// + /// Gets or Sets TotalRecalculations + /// + [JsonPropertyName("totalRecalculations")] + public int TotalRecalculations { get; set; } + + /// + /// Gets or Sets TotalSkips + /// + [JsonPropertyName("totalSkips")] + public int TotalSkips { get; set; } + + /// + /// Gets or Sets TotalUnderPours + /// + [JsonPropertyName("totalUnderPours")] + public int TotalUnderPours { get; set; } + + /// + /// Used to track the state of BatchNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BatchNumberOption { get; private set; } + + /// + /// Gets or Sets BatchNumber + /// + [JsonPropertyName("batchNumber")] + public string BatchNumber { get { return this.BatchNumberOption; } set { this.BatchNumberOption = new Option(value); } } + + /// + /// Used to track the state of BrandCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandCodeOption { get; private set; } + + /// + /// BrandCode is only required for non-color mixes + /// + /// BrandCode is only required for non-color mixes + [JsonPropertyName("brandCode")] + public string BrandCode { get { return this.BrandCodeOption; } set { this.BrandCodeOption = new Option(value); } } + + /// + /// Used to track the state of BrandId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandIdOption { get; private set; } + + /// + /// BrandId is only required for color mixes + /// + /// BrandId is only required for color mixes + [JsonPropertyName("brandId")] + public string BrandId { get { return this.BrandIdOption; } set { this.BrandIdOption = new Option(value); } } + + /// + /// Used to track the state of BrandName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandNameOption { get; private set; } + + /// + /// BrandName is only required for color mixes + /// + /// BrandName is only required for color mixes + [JsonPropertyName("brandName")] + public string BrandName { get { return this.BrandNameOption; } set { this.BrandNameOption = new Option(value); } } + + /// + /// Used to track the state of CategoryCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryCodeOption { get; private set; } + + /// + /// CategoryCode is not used anymore + /// + /// CategoryCode is not used anymore + [JsonPropertyName("categoryCode")] + public string CategoryCode { get { return this.CategoryCodeOption; } set { this.CategoryCodeOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Color is only required for color mixes + /// + /// Color is only required for color mixes + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Used to track the state of ColorDescription + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorDescriptionOption { get; private set; } + + /// + /// Gets or Sets ColorDescription + /// + [JsonPropertyName("colorDescription")] + public string ColorDescription { get { return this.ColorDescriptionOption; } set { this.ColorDescriptionOption = new Option(value); } } + + /// + /// Used to track the state of Comment + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CommentOption { get; private set; } + + /// + /// Gets or Sets Comment + /// + [JsonPropertyName("comment")] + public string Comment { get { return this.CommentOption; } set { this.CommentOption = new Option(value); } } + + /// + /// Used to track the state of CommercialProductCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CommercialProductCodeOption { get; private set; } + + /// + /// Gets or Sets CommercialProductCode + /// + [JsonPropertyName("commercialProductCode")] + public string CommercialProductCode { get { return this.CommercialProductCodeOption; } set { this.CommercialProductCodeOption = new Option(value); } } + + /// + /// Used to track the state of Country + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountryOption { get; private set; } + + /// + /// Gets or Sets Country + /// + [JsonPropertyName("country")] + public string Country { get { return this.CountryOption; } set { this.CountryOption = new Option(value); } } + + /// + /// Used to track the state of CreatedBy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByOption { get; private set; } + + /// + /// Gets or Sets CreatedBy + /// + [JsonPropertyName("createdBy")] + public string CreatedBy { get { return this.CreatedByOption; } set { this.CreatedByOption = new Option(value); } } + + /// + /// Used to track the state of CreatedByFirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByFirstNameOption { get; private set; } + + /// + /// Gets or Sets CreatedByFirstName + /// + [JsonPropertyName("createdByFirstName")] + public string CreatedByFirstName { get { return this.CreatedByFirstNameOption; } set { this.CreatedByFirstNameOption = new Option(value); } } + + /// + /// Used to track the state of CreatedByLastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByLastNameOption { get; private set; } + + /// + /// Gets or Sets CreatedByLastName + /// + [JsonPropertyName("createdByLastName")] + public string CreatedByLastName { get { return this.CreatedByLastNameOption; } set { this.CreatedByLastNameOption = new Option(value); } } + + /// + /// Used to track the state of DeltaECalculationRepaired + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeltaECalculationRepairedOption { get; private set; } + + /// + /// Gets or Sets DeltaECalculationRepaired + /// + [JsonPropertyName("deltaECalculationRepaired")] + public string DeltaECalculationRepaired { get { return this.DeltaECalculationRepairedOption; } set { this.DeltaECalculationRepairedOption = new Option(value); } } + + /// + /// Used to track the state of DeltaECalculationSprayout + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeltaECalculationSprayoutOption { get; private set; } + + /// + /// Gets or Sets DeltaECalculationSprayout + /// + [JsonPropertyName("deltaECalculationSprayout")] + public string DeltaECalculationSprayout { get { return this.DeltaECalculationSprayoutOption; } set { this.DeltaECalculationSprayoutOption = new Option(value); } } + + /// + /// Used to track the state of OwnColorVariantNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OwnColorVariantNumberOption { get; private set; } + + /// + /// Gets or Sets OwnColorVariantNumber + /// + [JsonPropertyName("ownColorVariantNumber")] + public int? OwnColorVariantNumber { get { return this.OwnColorVariantNumberOption; } set { this.OwnColorVariantNumberOption = new Option(value); } } + + /// + /// Used to track the state of PrimerProductId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PrimerProductIdOption { get; private set; } + + /// + /// Gets or Sets PrimerProductId + /// + [JsonPropertyName("primerProductId")] + public string PrimerProductId { get { return this.PrimerProductIdOption; } set { this.PrimerProductIdOption = new Option(value); } } + + /// + /// Used to track the state of ProductId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductIdOption { get; private set; } + + /// + /// ProductId is only required for color mixes + /// + /// ProductId is only required for color mixes + [JsonPropertyName("productId")] + public string ProductId { get { return this.ProductIdOption; } set { this.ProductIdOption = new Option(value); } } + + /// + /// Used to track the state of ProductLineCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductLineCodeOption { get; private set; } + + /// + /// ProductLineCode is only required for color mixes + /// + /// ProductLineCode is only required for color mixes + [JsonPropertyName("productLineCode")] + public string ProductLineCode { get { return this.ProductLineCodeOption; } set { this.ProductLineCodeOption = new Option(value); } } + + /// + /// Used to track the state of ProductName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductNameOption { get; private set; } + + /// + /// ProductName is only required for color mixes + /// + /// ProductName is only required for color mixes + [JsonPropertyName("productName")] + public string ProductName { get { return this.ProductNameOption; } set { this.ProductNameOption = new Option(value); } } + + /// + /// Used to track the state of SelectedVersionIndex + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SelectedVersionIndexOption { get; private set; } + + /// + /// Gets or Sets SelectedVersionIndex + /// + [JsonPropertyName("selectedVersionIndex")] + public int? SelectedVersionIndex { get { return this.SelectedVersionIndexOption; } set { this.SelectedVersionIndexOption = new Option(value); } } + + /// + /// Used to track the state of ShopId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShopIdOption { get; private set; } + + /// + /// Gets or Sets ShopId + /// + [JsonPropertyName("shopId")] + public Guid? ShopId { get { return this.ShopIdOption; } set { this.ShopIdOption = new Option(value); } } + + /// + /// Used to track the state of SomeCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomeCodeOption { get; private set; } + + /// + /// SomeCode is only required for color mixes + /// + /// SomeCode is only required for color mixes + [JsonPropertyName("someCode")] + public string SomeCode { get { return this.SomeCodeOption; } set { this.SomeCodeOption = new Option(value); } } + + /// + /// Used to track the state of TotalPrice + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TotalPriceOption { get; private set; } + + /// + /// Gets or Sets TotalPrice + /// + [JsonPropertyName("totalPrice")] + public float? TotalPrice { get { return this.TotalPriceOption; } set { this.TotalPriceOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixLog {\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append(" FormulaVersionDate: ").Append(FormulaVersionDate).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" MixDate: ").Append(MixDate).Append("\n"); + sb.Append(" TotalOverPoors: ").Append(TotalOverPoors).Append("\n"); + sb.Append(" TotalRecalculations: ").Append(TotalRecalculations).Append("\n"); + sb.Append(" TotalSkips: ").Append(TotalSkips).Append("\n"); + sb.Append(" TotalUnderPours: ").Append(TotalUnderPours).Append("\n"); + sb.Append(" BatchNumber: ").Append(BatchNumber).Append("\n"); + sb.Append(" BrandCode: ").Append(BrandCode).Append("\n"); + sb.Append(" BrandId: ").Append(BrandId).Append("\n"); + sb.Append(" BrandName: ").Append(BrandName).Append("\n"); + sb.Append(" CategoryCode: ").Append(CategoryCode).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" ColorDescription: ").Append(ColorDescription).Append("\n"); + sb.Append(" Comment: ").Append(Comment).Append("\n"); + sb.Append(" CommercialProductCode: ").Append(CommercialProductCode).Append("\n"); + sb.Append(" Country: ").Append(Country).Append("\n"); + sb.Append(" CreatedBy: ").Append(CreatedBy).Append("\n"); + sb.Append(" CreatedByFirstName: ").Append(CreatedByFirstName).Append("\n"); + sb.Append(" CreatedByLastName: ").Append(CreatedByLastName).Append("\n"); + sb.Append(" DeltaECalculationRepaired: ").Append(DeltaECalculationRepaired).Append("\n"); + sb.Append(" DeltaECalculationSprayout: ").Append(DeltaECalculationSprayout).Append("\n"); + sb.Append(" OwnColorVariantNumber: ").Append(OwnColorVariantNumber).Append("\n"); + sb.Append(" PrimerProductId: ").Append(PrimerProductId).Append("\n"); + sb.Append(" ProductId: ").Append(ProductId).Append("\n"); + sb.Append(" ProductLineCode: ").Append(ProductLineCode).Append("\n"); + sb.Append(" ProductName: ").Append(ProductName).Append("\n"); + sb.Append(" SelectedVersionIndex: ").Append(SelectedVersionIndex).Append("\n"); + sb.Append(" ShopId: ").Append(ShopId).Append("\n"); + sb.Append(" SomeCode: ").Append(SomeCode).Append("\n"); + sb.Append(" TotalPrice: ").Append(TotalPrice).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MixLogJsonConverter : JsonConverter + { + /// + /// The format to use to serialize FormulaVersionDate + /// + public static string FormulaVersionDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize MixDate + /// + public static string MixDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixLog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option description = default; + Option formulaVersionDate = default; + Option id = default; + Option mixDate = default; + Option totalOverPoors = default; + Option totalRecalculations = default; + Option totalSkips = default; + Option totalUnderPours = default; + Option batchNumber = default; + Option brandCode = default; + Option brandId = default; + Option brandName = default; + Option categoryCode = default; + Option color = default; + Option colorDescription = default; + Option comment = default; + Option commercialProductCode = default; + Option country = default; + Option createdBy = default; + Option createdByFirstName = default; + Option createdByLastName = default; + Option deltaECalculationRepaired = default; + Option deltaECalculationSprayout = default; + Option ownColorVariantNumber = default; + Option primerProductId = default; + Option productId = default; + Option productLineCode = default; + Option productName = default; + Option selectedVersionIndex = default; + Option shopId = default; + Option someCode = default; + Option totalPrice = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "description": + description = new Option(utf8JsonReader.GetString()); + break; + case "formulaVersionDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + formulaVersionDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetGuid()); + break; + case "mixDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mixDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "totalOverPoors": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalOverPoors = new Option(utf8JsonReader.GetInt32()); + break; + case "totalRecalculations": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalRecalculations = new Option(utf8JsonReader.GetInt32()); + break; + case "totalSkips": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalSkips = new Option(utf8JsonReader.GetInt32()); + break; + case "totalUnderPours": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalUnderPours = new Option(utf8JsonReader.GetInt32()); + break; + case "batchNumber": + batchNumber = new Option(utf8JsonReader.GetString()); + break; + case "brandCode": + brandCode = new Option(utf8JsonReader.GetString()); + break; + case "brandId": + brandId = new Option(utf8JsonReader.GetString()); + break; + case "brandName": + brandName = new Option(utf8JsonReader.GetString()); + break; + case "categoryCode": + categoryCode = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + case "colorDescription": + colorDescription = new Option(utf8JsonReader.GetString()); + break; + case "comment": + comment = new Option(utf8JsonReader.GetString()); + break; + case "commercialProductCode": + commercialProductCode = new Option(utf8JsonReader.GetString()); + break; + case "country": + country = new Option(utf8JsonReader.GetString()); + break; + case "createdBy": + createdBy = new Option(utf8JsonReader.GetString()); + break; + case "createdByFirstName": + createdByFirstName = new Option(utf8JsonReader.GetString()); + break; + case "createdByLastName": + createdByLastName = new Option(utf8JsonReader.GetString()); + break; + case "deltaECalculationRepaired": + deltaECalculationRepaired = new Option(utf8JsonReader.GetString()); + break; + case "deltaECalculationSprayout": + deltaECalculationSprayout = new Option(utf8JsonReader.GetString()); + break; + case "ownColorVariantNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + ownColorVariantNumber = new Option(utf8JsonReader.GetInt32()); + break; + case "primerProductId": + primerProductId = new Option(utf8JsonReader.GetString()); + break; + case "productId": + productId = new Option(utf8JsonReader.GetString()); + break; + case "productLineCode": + productLineCode = new Option(utf8JsonReader.GetString()); + break; + case "productName": + productName = new Option(utf8JsonReader.GetString()); + break; + case "selectedVersionIndex": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + selectedVersionIndex = new Option(utf8JsonReader.GetInt32()); + break; + case "shopId": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shopId = new Option(utf8JsonReader.GetGuid()); + break; + case "someCode": + someCode = new Option(utf8JsonReader.GetString()); + break; + case "totalPrice": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalPrice = new Option((float)utf8JsonReader.GetDouble()); + break; + default: + break; + } + } + } + + if (!description.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(description)); + + if (!formulaVersionDate.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(formulaVersionDate)); + + if (!id.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(id)); + + if (!mixDate.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(mixDate)); + + if (!totalOverPoors.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalOverPoors)); + + if (!totalRecalculations.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalRecalculations)); + + if (!totalSkips.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalSkips)); + + if (!totalUnderPours.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalUnderPours)); + + if (description.IsSet && description.Value == null) + throw new ArgumentNullException(nameof(description), "Property is not nullable for class MixLog."); + + if (formulaVersionDate.IsSet && formulaVersionDate.Value == null) + throw new ArgumentNullException(nameof(formulaVersionDate), "Property is not nullable for class MixLog."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixLog."); + + if (mixDate.IsSet && mixDate.Value == null) + throw new ArgumentNullException(nameof(mixDate), "Property is not nullable for class MixLog."); + + if (totalOverPoors.IsSet && totalOverPoors.Value == null) + throw new ArgumentNullException(nameof(totalOverPoors), "Property is not nullable for class MixLog."); + + if (totalRecalculations.IsSet && totalRecalculations.Value == null) + throw new ArgumentNullException(nameof(totalRecalculations), "Property is not nullable for class MixLog."); + + if (totalSkips.IsSet && totalSkips.Value == null) + throw new ArgumentNullException(nameof(totalSkips), "Property is not nullable for class MixLog."); + + if (totalUnderPours.IsSet && totalUnderPours.Value == null) + throw new ArgumentNullException(nameof(totalUnderPours), "Property is not nullable for class MixLog."); + + if (batchNumber.IsSet && batchNumber.Value == null) + throw new ArgumentNullException(nameof(batchNumber), "Property is not nullable for class MixLog."); + + if (brandCode.IsSet && brandCode.Value == null) + throw new ArgumentNullException(nameof(brandCode), "Property is not nullable for class MixLog."); + + if (brandId.IsSet && brandId.Value == null) + throw new ArgumentNullException(nameof(brandId), "Property is not nullable for class MixLog."); + + if (brandName.IsSet && brandName.Value == null) + throw new ArgumentNullException(nameof(brandName), "Property is not nullable for class MixLog."); + + if (categoryCode.IsSet && categoryCode.Value == null) + throw new ArgumentNullException(nameof(categoryCode), "Property is not nullable for class MixLog."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class MixLog."); + + if (colorDescription.IsSet && colorDescription.Value == null) + throw new ArgumentNullException(nameof(colorDescription), "Property is not nullable for class MixLog."); + + if (comment.IsSet && comment.Value == null) + throw new ArgumentNullException(nameof(comment), "Property is not nullable for class MixLog."); + + if (commercialProductCode.IsSet && commercialProductCode.Value == null) + throw new ArgumentNullException(nameof(commercialProductCode), "Property is not nullable for class MixLog."); + + if (country.IsSet && country.Value == null) + throw new ArgumentNullException(nameof(country), "Property is not nullable for class MixLog."); + + if (createdBy.IsSet && createdBy.Value == null) + throw new ArgumentNullException(nameof(createdBy), "Property is not nullable for class MixLog."); + + if (createdByFirstName.IsSet && createdByFirstName.Value == null) + throw new ArgumentNullException(nameof(createdByFirstName), "Property is not nullable for class MixLog."); + + if (createdByLastName.IsSet && createdByLastName.Value == null) + throw new ArgumentNullException(nameof(createdByLastName), "Property is not nullable for class MixLog."); + + if (deltaECalculationRepaired.IsSet && deltaECalculationRepaired.Value == null) + throw new ArgumentNullException(nameof(deltaECalculationRepaired), "Property is not nullable for class MixLog."); + + if (deltaECalculationSprayout.IsSet && deltaECalculationSprayout.Value == null) + throw new ArgumentNullException(nameof(deltaECalculationSprayout), "Property is not nullable for class MixLog."); + + if (primerProductId.IsSet && primerProductId.Value == null) + throw new ArgumentNullException(nameof(primerProductId), "Property is not nullable for class MixLog."); + + if (productId.IsSet && productId.Value == null) + throw new ArgumentNullException(nameof(productId), "Property is not nullable for class MixLog."); + + if (productLineCode.IsSet && productLineCode.Value == null) + throw new ArgumentNullException(nameof(productLineCode), "Property is not nullable for class MixLog."); + + if (productName.IsSet && productName.Value == null) + throw new ArgumentNullException(nameof(productName), "Property is not nullable for class MixLog."); + + if (selectedVersionIndex.IsSet && selectedVersionIndex.Value == null) + throw new ArgumentNullException(nameof(selectedVersionIndex), "Property is not nullable for class MixLog."); + + if (shopId.IsSet && shopId.Value == null) + throw new ArgumentNullException(nameof(shopId), "Property is not nullable for class MixLog."); + + return new MixLog(description.Value, formulaVersionDate.Value.Value, id.Value.Value, mixDate.Value.Value, totalOverPoors.Value.Value, totalRecalculations.Value.Value, totalSkips.Value.Value, totalUnderPours.Value.Value, batchNumber, brandCode, brandId, brandName, categoryCode, color, colorDescription, comment, commercialProductCode, country, createdBy, createdByFirstName, createdByLastName, deltaECalculationRepaired, deltaECalculationSprayout, ownColorVariantNumber, primerProductId, productId, productLineCode, productName, selectedVersionIndex, shopId, someCode, totalPrice); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixLog mixLog, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixLog, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixLog mixLog, JsonSerializerOptions jsonSerializerOptions) + { + if (mixLog.Description == null) + throw new ArgumentNullException(nameof(mixLog.Description), "Property is required for class MixLog."); + + if (mixLog.BatchNumberOption.IsSet && mixLog.BatchNumber == null) + throw new ArgumentNullException(nameof(mixLog.BatchNumber), "Property is required for class MixLog."); + + if (mixLog.BrandCodeOption.IsSet && mixLog.BrandCode == null) + throw new ArgumentNullException(nameof(mixLog.BrandCode), "Property is required for class MixLog."); + + if (mixLog.BrandIdOption.IsSet && mixLog.BrandId == null) + throw new ArgumentNullException(nameof(mixLog.BrandId), "Property is required for class MixLog."); + + if (mixLog.BrandNameOption.IsSet && mixLog.BrandName == null) + throw new ArgumentNullException(nameof(mixLog.BrandName), "Property is required for class MixLog."); + + if (mixLog.CategoryCodeOption.IsSet && mixLog.CategoryCode == null) + throw new ArgumentNullException(nameof(mixLog.CategoryCode), "Property is required for class MixLog."); + + if (mixLog.ColorOption.IsSet && mixLog.Color == null) + throw new ArgumentNullException(nameof(mixLog.Color), "Property is required for class MixLog."); + + if (mixLog.ColorDescriptionOption.IsSet && mixLog.ColorDescription == null) + throw new ArgumentNullException(nameof(mixLog.ColorDescription), "Property is required for class MixLog."); + + if (mixLog.CommentOption.IsSet && mixLog.Comment == null) + throw new ArgumentNullException(nameof(mixLog.Comment), "Property is required for class MixLog."); + + if (mixLog.CommercialProductCodeOption.IsSet && mixLog.CommercialProductCode == null) + throw new ArgumentNullException(nameof(mixLog.CommercialProductCode), "Property is required for class MixLog."); + + if (mixLog.CountryOption.IsSet && mixLog.Country == null) + throw new ArgumentNullException(nameof(mixLog.Country), "Property is required for class MixLog."); + + if (mixLog.CreatedByOption.IsSet && mixLog.CreatedBy == null) + throw new ArgumentNullException(nameof(mixLog.CreatedBy), "Property is required for class MixLog."); + + if (mixLog.CreatedByFirstNameOption.IsSet && mixLog.CreatedByFirstName == null) + throw new ArgumentNullException(nameof(mixLog.CreatedByFirstName), "Property is required for class MixLog."); + + if (mixLog.CreatedByLastNameOption.IsSet && mixLog.CreatedByLastName == null) + throw new ArgumentNullException(nameof(mixLog.CreatedByLastName), "Property is required for class MixLog."); + + if (mixLog.DeltaECalculationRepairedOption.IsSet && mixLog.DeltaECalculationRepaired == null) + throw new ArgumentNullException(nameof(mixLog.DeltaECalculationRepaired), "Property is required for class MixLog."); + + if (mixLog.DeltaECalculationSprayoutOption.IsSet && mixLog.DeltaECalculationSprayout == null) + throw new ArgumentNullException(nameof(mixLog.DeltaECalculationSprayout), "Property is required for class MixLog."); + + if (mixLog.PrimerProductIdOption.IsSet && mixLog.PrimerProductId == null) + throw new ArgumentNullException(nameof(mixLog.PrimerProductId), "Property is required for class MixLog."); + + if (mixLog.ProductIdOption.IsSet && mixLog.ProductId == null) + throw new ArgumentNullException(nameof(mixLog.ProductId), "Property is required for class MixLog."); + + if (mixLog.ProductLineCodeOption.IsSet && mixLog.ProductLineCode == null) + throw new ArgumentNullException(nameof(mixLog.ProductLineCode), "Property is required for class MixLog."); + + if (mixLog.ProductNameOption.IsSet && mixLog.ProductName == null) + throw new ArgumentNullException(nameof(mixLog.ProductName), "Property is required for class MixLog."); + + writer.WriteString("description", mixLog.Description); + + writer.WriteString("formulaVersionDate", mixLog.FormulaVersionDate.ToString(FormulaVersionDateFormat)); + + writer.WriteString("id", mixLog.Id); + + writer.WriteString("mixDate", mixLog.MixDate.ToString(MixDateFormat)); + + writer.WriteNumber("totalOverPoors", mixLog.TotalOverPoors); + + writer.WriteNumber("totalRecalculations", mixLog.TotalRecalculations); + + writer.WriteNumber("totalSkips", mixLog.TotalSkips); + + writer.WriteNumber("totalUnderPours", mixLog.TotalUnderPours); + + if (mixLog.BatchNumberOption.IsSet) + writer.WriteString("batchNumber", mixLog.BatchNumber); + + if (mixLog.BrandCodeOption.IsSet) + writer.WriteString("brandCode", mixLog.BrandCode); + + if (mixLog.BrandIdOption.IsSet) + writer.WriteString("brandId", mixLog.BrandId); + + if (mixLog.BrandNameOption.IsSet) + writer.WriteString("brandName", mixLog.BrandName); + + if (mixLog.CategoryCodeOption.IsSet) + writer.WriteString("categoryCode", mixLog.CategoryCode); + + if (mixLog.ColorOption.IsSet) + writer.WriteString("color", mixLog.Color); + + if (mixLog.ColorDescriptionOption.IsSet) + writer.WriteString("colorDescription", mixLog.ColorDescription); + + if (mixLog.CommentOption.IsSet) + writer.WriteString("comment", mixLog.Comment); + + if (mixLog.CommercialProductCodeOption.IsSet) + writer.WriteString("commercialProductCode", mixLog.CommercialProductCode); + + if (mixLog.CountryOption.IsSet) + writer.WriteString("country", mixLog.Country); + + if (mixLog.CreatedByOption.IsSet) + writer.WriteString("createdBy", mixLog.CreatedBy); + + if (mixLog.CreatedByFirstNameOption.IsSet) + writer.WriteString("createdByFirstName", mixLog.CreatedByFirstName); + + if (mixLog.CreatedByLastNameOption.IsSet) + writer.WriteString("createdByLastName", mixLog.CreatedByLastName); + + if (mixLog.DeltaECalculationRepairedOption.IsSet) + writer.WriteString("deltaECalculationRepaired", mixLog.DeltaECalculationRepaired); + + if (mixLog.DeltaECalculationSprayoutOption.IsSet) + writer.WriteString("deltaECalculationSprayout", mixLog.DeltaECalculationSprayout); + + if (mixLog.OwnColorVariantNumberOption.IsSet) + if (mixLog.OwnColorVariantNumberOption.Value != null) + writer.WriteNumber("ownColorVariantNumber", mixLog.OwnColorVariantNumberOption.Value.Value); + else + writer.WriteNull("ownColorVariantNumber"); + + if (mixLog.PrimerProductIdOption.IsSet) + writer.WriteString("primerProductId", mixLog.PrimerProductId); + + if (mixLog.ProductIdOption.IsSet) + writer.WriteString("productId", mixLog.ProductId); + + if (mixLog.ProductLineCodeOption.IsSet) + writer.WriteString("productLineCode", mixLog.ProductLineCode); + + if (mixLog.ProductNameOption.IsSet) + writer.WriteString("productName", mixLog.ProductName); + + if (mixLog.SelectedVersionIndexOption.IsSet) + writer.WriteNumber("selectedVersionIndex", mixLog.SelectedVersionIndexOption.Value.Value); + + if (mixLog.ShopIdOption.IsSet) + writer.WriteString("shopId", mixLog.ShopIdOption.Value.Value); + + if (mixLog.SomeCodeOption.IsSet) + if (mixLog.SomeCodeOption.Value != null) + writer.WriteString("someCode", mixLog.SomeCode); + else + writer.WriteNull("someCode"); + + if (mixLog.TotalPriceOption.IsSet) + if (mixLog.TotalPriceOption.Value != null) + writer.WriteNumber("totalPrice", mixLog.TotalPriceOption.Value.Value); + else + writer.WriteNull("totalPrice"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs new file mode 100644 index 000000000000..095c00f45621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -0,0 +1,270 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedPropertiesAndAdditionalPropertiesClass + /// + public partial class MixedPropertiesAndAdditionalPropertiesClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateTime + /// map + /// uuid + /// uuidWithPattern + [JsonConstructor] + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option> map = default, Option uuid = default, Option uuidWithPattern = default) + { + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this.DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOption { get; private set; } + + /// + /// Gets or Sets Map + /// + [JsonPropertyName("map")] + public Dictionary Map { get { return this.MapOption; } set { this.MapOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } + + /// + /// Gets or Sets UuidWithPattern + /// + [JsonPropertyName("uuid_with_pattern")] + public Guid? UuidWithPattern { get { return this.UuidWithPatternOption; } set { this.UuidWithPatternOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Map: ").Append(Map).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" UuidWithPattern: ").Append(UuidWithPattern).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + // UuidWithPattern (Guid) pattern + Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); + } + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MixedPropertiesAndAdditionalPropertiesClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateTime + /// + public static string DateTimeFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option dateTime = default; + Option> map = default; + Option uuid = default; + Option uuidWithPattern = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + map = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + case "uuid_with_pattern": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs new file mode 100644 index 000000000000..8c0a59ace8bd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model name starting with number + /// + public partial class Model200Response : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// class + /// name + [JsonConstructor] + public Model200Response(Option @class = default, Option name = default) + { + ClassOption = @class; + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Class + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ClassOption { get; private set; } + + /// + /// Gets or Sets Class + /// + [JsonPropertyName("class")] + public string Class { get { return this.ClassOption; } set { this.ClassOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public int? Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Model200Response {\n"); + sb.Append(" Class: ").Append(Class).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class Model200ResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClass = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "class": + varClass = new Option(utf8JsonReader.GetString()); + break; + case "name": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + name = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); + + return new Model200Response(varClass, name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, model200Response, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + { + if (model200Response.ClassOption.IsSet && model200Response.Class == null) + throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response."); + + if (model200Response.ClassOption.IsSet) + writer.WriteString("class", model200Response.Class); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs new file mode 100644 index 000000000000..e8cca355d288 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ModelClient + /// + public partial class ModelClient : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varClient + [JsonConstructor] + public ModelClient(Option varClient = default) + { + VarClientOption = varClient; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + + /// + /// Gets or Sets VarClient + /// + [JsonPropertyName("client")] + public string VarClient { get { return this.VarClientOption; } set { this.VarClientOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ModelClient {\n"); + sb.Append(" VarClient: ").Append(VarClient).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ModelClientJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClient = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "client": + varClient = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); + + return new ModelClient(varClient); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, modelClient, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + { + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs new file mode 100644 index 000000000000..90a80bda8815 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Name.cs @@ -0,0 +1,291 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model name same as property name + /// + public partial class Name : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varName + /// property + /// snakeCase + /// var123Number + [JsonConstructor] + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) + { + VarName = varName; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets VarName + /// + [JsonPropertyName("name")] + public int VarName { get; set; } + + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + + /// + /// Gets or Sets Property + /// + [JsonPropertyName("property")] + public string Property { get { return this.PropertyOption; } set { this.PropertyOption = new Option(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } + + /// + /// Gets or Sets SnakeCase + /// + [JsonPropertyName("snake_case")] + public int? SnakeCase { get { return this.SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } + + /// + /// Gets or Sets Var123Number + /// + [JsonPropertyName("123Number")] + public int? Var123Number { get { return this.Var123NumberOption; } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Name {\n"); + sb.Append(" VarName: ").Append(VarName).Append("\n"); + sb.Append(" Property: ").Append(Property).Append("\n"); + sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); + sb.Append(" Var123Number: ").Append(Var123Number).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as Name).AreEqual; + } + + /// + /// Returns true if Name instances are equal + /// + /// Instance of Name to be compared + /// Boolean + public bool Equals(Name input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NameJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varName = new Option(utf8JsonReader.GetInt32()); + break; + case "property": + property = new Option(utf8JsonReader.GetString()); + break; + case "snake_case": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + snakeCase = new Option(utf8JsonReader.GetInt32()); + break; + case "123Number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + var123Number = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); + + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); + + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); + + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); + + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value.Value, property, snakeCase, var123Number); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, name, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + + writer.WriteNumber("name", name.VarName); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs new file mode 100644 index 000000000000..d10268f2927a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -0,0 +1,192 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NotificationtestGetElementsV1ResponseMPayload + /// + public partial class NotificationtestGetElementsV1ResponseMPayload : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// aObjVariableobject + /// pkiNotificationtestID + [JsonConstructor] + public NotificationtestGetElementsV1ResponseMPayload(List> aObjVariableobject, int pkiNotificationtestID) + { + AObjVariableobject = aObjVariableobject; + PkiNotificationtestID = pkiNotificationtestID; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets AObjVariableobject + /// + [JsonPropertyName("a_objVariableobject")] + public List> AObjVariableobject { get; set; } + + /// + /// Gets or Sets PkiNotificationtestID + /// + [JsonPropertyName("pkiNotificationtestID")] + public int PkiNotificationtestID { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NotificationtestGetElementsV1ResponseMPayload {\n"); + sb.Append(" AObjVariableobject: ").Append(AObjVariableobject).Append("\n"); + sb.Append(" PkiNotificationtestID: ").Append(PkiNotificationtestID).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NotificationtestGetElementsV1ResponseMPayloadJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NotificationtestGetElementsV1ResponseMPayload Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> aObjVariableobject = default; + Option pkiNotificationtestID = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "a_objVariableobject": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + aObjVariableobject = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "pkiNotificationtestID": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); + + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); + + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value, pkiNotificationtestID.Value.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + + writer.WritePropertyName("a_objVariableobject"); + JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); + writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs new file mode 100644 index 000000000000..f844fec808c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs @@ -0,0 +1,496 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NullableClass + /// + public partial class NullableClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayAndItemsNullableProp + /// arrayItemsNullable + /// arrayNullableProp + /// booleanProp + /// dateProp + /// datetimeProp + /// integerProp + /// numberProp + /// objectAndItemsNullableProp + /// objectItemsNullable + /// objectNullableProp + /// stringProp + [JsonConstructor] + public NullableClass(Option> arrayAndItemsNullableProp = default, Option> arrayItemsNullable = default, Option> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option> objectAndItemsNullableProp = default, Option> objectItemsNullable = default, Option> objectNullableProp = default, Option stringProp = default) + { + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayAndItemsNullablePropOption { get; private set; } + + /// + /// Gets or Sets ArrayAndItemsNullableProp + /// + [JsonPropertyName("array_and_items_nullable_prop")] + public List ArrayAndItemsNullableProp { get { return this.ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List ArrayItemsNullable { get { return this.ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNullablePropOption { get; private set; } + + /// + /// Gets or Sets ArrayNullableProp + /// + [JsonPropertyName("array_nullable_prop")] + public List ArrayNullableProp { get { return this.ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } + + /// + /// Gets or Sets BooleanProp + /// + [JsonPropertyName("boolean_prop")] + public bool? BooleanProp { get { return this.BooleanPropOption; } set { this.BooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } + + /// + /// Gets or Sets DateProp + /// + [JsonPropertyName("date_prop")] + public DateTime? DateProp { get { return this.DatePropOption; } set { this.DatePropOption = new Option(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } + + /// + /// Gets or Sets DatetimeProp + /// + [JsonPropertyName("datetime_prop")] + public DateTime? DatetimeProp { get { return this.DatetimePropOption; } set { this.DatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } + + /// + /// Gets or Sets IntegerProp + /// + [JsonPropertyName("integer_prop")] + public int? IntegerProp { get { return this.IntegerPropOption; } set { this.IntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } + + /// + /// Gets or Sets NumberProp + /// + [JsonPropertyName("number_prop")] + public decimal? NumberProp { get { return this.NumberPropOption; } set { this.NumberPropOption = new Option(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectAndItemsNullablePropOption { get; private set; } + + /// + /// Gets or Sets ObjectAndItemsNullableProp + /// + [JsonPropertyName("object_and_items_nullable_prop")] + public Dictionary ObjectAndItemsNullableProp { get { return this.ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary ObjectItemsNullable { get { return this.ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectNullablePropOption { get; private set; } + + /// + /// Gets or Sets ObjectNullableProp + /// + [JsonPropertyName("object_nullable_prop")] + public Dictionary ObjectNullableProp { get { return this.ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } + + /// + /// Gets or Sets StringProp + /// + [JsonPropertyName("string_prop")] + public string StringProp { get { return this.StringPropOption; } set { this.StringPropOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableClass {\n"); + sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); + sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); + sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); + sb.Append(" DateProp: ").Append(DateProp).Append("\n"); + sb.Append(" DatetimeProp: ").Append(DatetimeProp).Append("\n"); + sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); + sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); + sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); + sb.Append(" StringProp: ").Append(StringProp).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateProp + /// + public static string DatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize DatetimeProp + /// + public static string DatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayAndItemsNullableProp = default; + Option> arrayItemsNullable = default; + Option> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option> objectAndItemsNullableProp = default; + Option> objectItemsNullable = default; + Option> objectNullableProp = default; + Option stringProp = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_and_items_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + booleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "number_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + numberProp = new Option(utf8JsonReader.GetDecimal()); + break; + case "object_and_items_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "string_prop": + stringProp = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); + + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); + + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, nullableClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + { + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); + + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); + + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value.Value); + else + writer.WriteNull("boolean_prop"); + + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); + + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); + + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value.Value); + else + writer.WriteNull("integer_prop"); + + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs new file mode 100644 index 000000000000..ef86eb595aca --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -0,0 +1,173 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NullableGuidClass + /// + public partial class NullableGuidClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// uuid + [JsonConstructor] + public NullableGuidClass(Option uuid = default) + { + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableGuidClass {\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableGuidClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableGuidClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + return new NullableGuidClass(uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + { + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value.Value); + else + writer.WriteNull("uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs new file mode 100644 index 000000000000..10061a2c228b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + /// + public partial class NullableShape : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public NullableShape(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public NullableShape(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableShape {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableShapeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); + + if (quadrilateral != null) + return new NullableShape(quadrilateral); + + if (triangle != null) + return new NullableShape(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (nullableShape.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); + } + + if (nullableShape.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, nullableShape, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs new file mode 100644 index 000000000000..2b602ec80d78 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -0,0 +1,172 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NumberOnly + /// + public partial class NumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// justNumber + [JsonConstructor] + public NumberOnly(Option justNumber = default) + { + JustNumberOption = justNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + + /// + /// Gets or Sets JustNumber + /// + [JsonPropertyName("JustNumber")] + public decimal? JustNumber { get { return this.JustNumberOption; } set { this.JustNumberOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NumberOnly {\n"); + sb.Append(" JustNumber: ").Append(JustNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option justNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "JustNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + justNumber = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); + + return new NumberOnly(justNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, numberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs new file mode 100644 index 000000000000..5cc97e836da0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -0,0 +1,268 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ObjectWithDeprecatedFields + /// + public partial class ObjectWithDeprecatedFields : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bars + /// deprecatedRef + /// id + /// uuid + [JsonConstructor] + public ObjectWithDeprecatedFields(Option> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) + { + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> BarsOption { get; private set; } + + /// + /// Gets or Sets Bars + /// + [JsonPropertyName("bars")] + [Obsolete] + public List Bars { get { return this.BarsOption; } set { this.BarsOption = new Option>(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } + + /// + /// Gets or Sets DeprecatedRef + /// + [JsonPropertyName("deprecatedRef")] + [Obsolete] + public DeprecatedObject DeprecatedRef { get { return this.DeprecatedRefOption; } set { this.DeprecatedRefOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + [Obsolete] + public decimal? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ObjectWithDeprecatedFields {\n"); + sb.Append(" Bars: ").Append(Bars).Append("\n"); + sb.Append(" DeprecatedRef: ").Append(DeprecatedRef).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ObjectWithDeprecatedFieldsJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bars": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + bars = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "deprecatedRef": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetDecimal()); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); + + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + { + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs new file mode 100644 index 000000000000..0f4f13f311b0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs @@ -0,0 +1,157 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// OneOfString + /// + public partial class OneOfString : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + internal OneOfString(string @string) + { + String = @string; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class OneOfString {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OneOfStringJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override OneOfString Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + string varString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (varString != null) + return new OneOfString(varString); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, oneOfString, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs new file mode 100644 index 000000000000..eb55c251112a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Order.cs @@ -0,0 +1,317 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Order + /// + public partial class Order : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// complete (default to false) + /// id + /// petId + /// quantity + /// shipDate + /// status + [JsonConstructor] + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) + { + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + + /// + /// Gets or Sets Status + /// + [JsonPropertyName("status")] + public OrderStatus? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this.CompleteOption; } set { this.CompleteOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } + + /// + /// Gets or Sets PetId + /// + [JsonPropertyName("petId")] + public long? PetId { get { return this.PetIdOption; } set { this.PetIdOption = new Option(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } + + /// + /// Gets or Sets Quantity + /// + [JsonPropertyName("quantity")] + public int? Quantity { get { return this.QuantityOption; } set { this.QuantityOption = new Option(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } + + /// + /// Gets or Sets ShipDate + /// + /// 2020-02-02T20:20:20.000222Z + [JsonPropertyName("shipDate")] + public DateTime? ShipDate { get { return this.ShipDateOption; } set { this.ShipDateOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\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(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OrderJsonConverter : JsonConverter + { + /// + /// The format to use to serialize ShipDate + /// + public static string ShipDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "petId": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + petId = new Option(utf8JsonReader.GetInt64()); + break; + case "quantity": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + quantity = new Option(utf8JsonReader.GetInt32()); + break; + case "shipDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "status": + string statusRawValue = utf8JsonReader.GetString(); + if (statusRawValue != null) + status = new Option(OrderStatusValueConverter.FromStringOrDefault(statusRawValue)); + break; + default: + break; + } + } + } + + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); + + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); + + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); + + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); + + return new Order(complete, id, petId, quantity, shipDate, status); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, order, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + { + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value.Value); + + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat)); + + if (order.StatusOption.IsSet) + { + var statusRawValue = OrderStatusValueConverter.ToJsonValue(order.Status.Value); + writer.WriteString("status", statusRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OrderStatus.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OrderStatus.cs new file mode 100644 index 000000000000..6566ca4aa564 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OrderStatus.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Order Status + /// + /// Order Status + public enum OrderStatus + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class OrderStatusValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OrderStatus FromString(string value) + { + if (value.Equals("placed")) + return OrderStatus.Placed; + + if (value.Equals("approved")) + return OrderStatus.Approved; + + if (value.Equals("delivered")) + return OrderStatus.Delivered; + + throw new NotImplementedException($"Could not convert value to type OrderStatus: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OrderStatus? FromStringOrDefault(string value) + { + if (value.Equals("placed")) + return OrderStatus.Placed; + + if (value.Equals("approved")) + return OrderStatus.Approved; + + if (value.Equals("delivered")) + return OrderStatus.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OrderStatus value) + { + if (value == OrderStatus.Placed) + return "placed"; + + if (value == OrderStatus.Approved) + return "approved"; + + if (value == OrderStatus.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OrderStatusJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OrderStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OrderStatus? result = rawValue == null + ? null + : OrderStatusValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OrderStatus to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OrderStatus orderStatus, JsonSerializerOptions options) + { + writer.WriteStringValue(orderStatus.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OrderStatusNullableJsonConverter : JsonConverter + { + /// + /// Returns a OrderStatus from the Json object + /// + /// + /// + /// + /// + public override OrderStatus? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OrderStatus? result = rawValue == null + ? null + : OrderStatusValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OrderStatus? orderStatus, JsonSerializerOptions options) + { + writer.WriteStringValue(orderStatus?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs new file mode 100644 index 000000000000..bb1af3218659 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -0,0 +1,228 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// OuterComposite + /// + public partial class OuterComposite : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// myBoolean + /// myNumber + /// myString + [JsonConstructor] + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) + { + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + + /// + /// Gets or Sets MyBoolean + /// + [JsonPropertyName("my_boolean")] + public bool? MyBoolean { get { return this.MyBooleanOption; } set { this.MyBooleanOption = new Option(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } + + /// + /// Gets or Sets MyNumber + /// + [JsonPropertyName("my_number")] + public decimal? MyNumber { get { return this.MyNumberOption; } set { this.MyNumberOption = new Option(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } + + /// + /// Gets or Sets MyString + /// + [JsonPropertyName("my_string")] + public string MyString { get { return this.MyStringOption; } set { this.MyStringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class OuterComposite {\n"); + sb.Append(" MyBoolean: ").Append(MyBoolean).Append("\n"); + sb.Append(" MyNumber: ").Append(MyNumber).Append("\n"); + sb.Append(" MyString: ").Append(MyString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OuterCompositeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option myBoolean = default; + Option myNumber = default; + Option myString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "my_boolean": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + myBoolean = new Option(utf8JsonReader.GetBoolean()); + break; + case "my_number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + myNumber = new Option(utf8JsonReader.GetDecimal()); + break; + case "my_string": + myString = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); + + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); + + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); + + return new OuterComposite(myBoolean, myNumber, myString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, outerComposite, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + { + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnum.cs new file mode 100644 index 000000000000..47bb6793c6ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnum + /// + public enum OuterEnum + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnum FromString(string value) + { + if (value.Equals("placed")) + return OuterEnum.Placed; + + if (value.Equals("approved")) + return OuterEnum.Approved; + + if (value.Equals("delivered")) + return OuterEnum.Delivered; + + throw new NotImplementedException($"Could not convert value to type OuterEnum: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnum? FromStringOrDefault(string value) + { + if (value.Equals("placed")) + return OuterEnum.Placed; + + if (value.Equals("approved")) + return OuterEnum.Approved; + + if (value.Equals("delivered")) + return OuterEnum.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnum value) + { + if (value == OuterEnum.Placed) + return "placed"; + + if (value == OuterEnum.Approved) + return "approved"; + + if (value == OuterEnum.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnum? result = rawValue == null + ? null + : OuterEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnum to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnum outerEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnum.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnum from the Json object + /// + /// + /// + /// + /// + public override OuterEnum? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnum? result = rawValue == null + ? null + : OuterEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnum? outerEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnum?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs new file mode 100644 index 000000000000..136fb4c54c4e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumDefaultValue + /// + public enum OuterEnumDefaultValue + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumDefaultValueValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumDefaultValue FromString(string value) + { + if (value.Equals("placed")) + return OuterEnumDefaultValue.Placed; + + if (value.Equals("approved")) + return OuterEnumDefaultValue.Approved; + + if (value.Equals("delivered")) + return OuterEnumDefaultValue.Delivered; + + throw new NotImplementedException($"Could not convert value to type OuterEnumDefaultValue: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumDefaultValue? FromStringOrDefault(string value) + { + if (value.Equals("placed")) + return OuterEnumDefaultValue.Placed; + + if (value.Equals("approved")) + return OuterEnumDefaultValue.Approved; + + if (value.Equals("delivered")) + return OuterEnumDefaultValue.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnumDefaultValue value) + { + if (value == OuterEnumDefaultValue.Placed) + return "placed"; + + if (value == OuterEnumDefaultValue.Approved) + return "approved"; + + if (value == OuterEnumDefaultValue.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumDefaultValueJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumDefaultValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumDefaultValue? result = rawValue == null + ? null + : OuterEnumDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumDefaultValue to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumDefaultValue outerEnumDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumDefaultValue.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumDefaultValueNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumDefaultValue from the Json object + /// + /// + /// + /// + /// + public override OuterEnumDefaultValue? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumDefaultValue? result = rawValue == null + ? null + : OuterEnumDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumDefaultValue? outerEnumDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumDefaultValue?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumInteger.cs new file mode 100644 index 000000000000..2ed4f18a657e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -0,0 +1,179 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumInteger + /// + public enum OuterEnumInteger + { + /// + /// Enum NUMBER_0 for value: 0 + /// + NUMBER_0 = 0, + + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumIntegerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumInteger FromString(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumInteger.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumInteger.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumInteger.NUMBER_2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumInteger: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumInteger? FromStringOrDefault(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumInteger.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumInteger.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumInteger.NUMBER_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(OuterEnumInteger value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumIntegerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumInteger? result = rawValue == null + ? null + : OuterEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumInteger to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumInteger outerEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumInteger.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumIntegerNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumInteger from the Json object + /// + /// + /// + /// + /// + public override OuterEnumInteger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumInteger? result = rawValue == null + ? null + : OuterEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumInteger? outerEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumInteger?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs new file mode 100644 index 000000000000..c6a470cc64d1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -0,0 +1,179 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumIntegerDefaultValue + /// + public enum OuterEnumIntegerDefaultValue + { + /// + /// Enum NUMBER_0 for value: 0 + /// + NUMBER_0 = 0, + + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumIntegerDefaultValueValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumIntegerDefaultValue FromString(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumIntegerDefaultValue: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumIntegerDefaultValue? FromStringOrDefault(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(OuterEnumIntegerDefaultValue value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumIntegerDefaultValueJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumIntegerDefaultValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumIntegerDefaultValue? result = rawValue == null + ? null + : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumIntegerDefaultValue to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumIntegerDefaultValue.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumIntegerDefaultValueNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumIntegerDefaultValue from the Json object + /// + /// + /// + /// + /// + public override OuterEnumIntegerDefaultValue? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumIntegerDefaultValue? result = rawValue == null + ? null + : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumIntegerDefaultValue?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumTest.cs new file mode 100644 index 000000000000..a2e789f2edef --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/OuterEnumTest.cs @@ -0,0 +1,258 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines Outer_Enum_Test + /// + public enum OuterEnumTest + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumTestValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumTest FromString(string value) + { + if (value.Equals("UPPER")) + return OuterEnumTest.UPPER; + + if (value.Equals("lower")) + return OuterEnumTest.Lower; + + if (value.Equals("")) + return OuterEnumTest.Empty; + + if (value.Equals("Value\twith tab")) + return OuterEnumTest.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return OuterEnumTest.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return OuterEnumTest.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return OuterEnumTest.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return OuterEnumTest.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumTest: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumTest? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return OuterEnumTest.UPPER; + + if (value.Equals("lower")) + return OuterEnumTest.Lower; + + if (value.Equals("")) + return OuterEnumTest.Empty; + + if (value.Equals("Value\twith tab")) + return OuterEnumTest.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return OuterEnumTest.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return OuterEnumTest.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return OuterEnumTest.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return OuterEnumTest.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnumTest value) + { + if (value == OuterEnumTest.UPPER) + return "UPPER"; + + if (value == OuterEnumTest.Lower) + return "lower"; + + if (value == OuterEnumTest.Empty) + return ""; + + if (value == OuterEnumTest.ValuewithTab) + return "Value\twith tab"; + + if (value == OuterEnumTest.ValueWithQuote) + return "Value with \" quote"; + + if (value == OuterEnumTest.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == OuterEnumTest.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == OuterEnumTest.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumTestJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumTest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumTest? result = rawValue == null + ? null + : OuterEnumTestValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumTest to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumTest outerEnumTest, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumTest.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumTestNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumTest from the Json object + /// + /// + /// + /// + /// + public override OuterEnumTest? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumTest? result = rawValue == null + ? null + : OuterEnumTestValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumTest? outerEnumTest, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumTest?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs new file mode 100644 index 000000000000..5d1cab769fa8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs @@ -0,0 +1,158 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ParentPet + /// + public partial class ParentPet : GrandparentAnimal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public ParentPet() : base() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string PetType { get; } = "ParentPet"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ParentPet {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class ParentPetJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option petType = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type"); + + if (discriminator != null && discriminator.Equals("ChildCat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "pet_type": + petType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, parentPet, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("pet_type", parentPet.PetType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs new file mode 100644 index 000000000000..110ad772c796 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pet.cs @@ -0,0 +1,317 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Pet + /// + public partial class Pet : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + /// photoUrls + /// category + /// id + /// status + /// tags + [JsonConstructor] + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option> tags = default) + { + Name = name; + PhotoUrls = photoUrls; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + + /// + /// Gets or Sets Status + /// + [JsonPropertyName("status")] + public PetStatus? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } + + /// + /// Gets or Sets Name + /// + /// doggie + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [JsonPropertyName("photoUrls")] + public List PhotoUrls { get; set; } + + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category Category { get { return this.CategoryOption; } set { this.CategoryOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TagsOption { get; private set; } + + /// + /// Gets or Sets Tags + /// + [JsonPropertyName("tags")] + public List Tags { get { return this.TagsOption; } set { this.TagsOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PetJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + Option> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option> tags = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + case "photoUrls": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + photoUrls = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "status": + string statusRawValue = utf8JsonReader.GetString(); + if (statusRawValue != null) + status = new Option(PetStatusValueConverter.FromStringOrDefault(statusRawValue)); + break; + case "tags": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + tags = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); + + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); + + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); + + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value, photoUrls.Value, category, id, status, tags); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, pet, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + { + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + + writer.WriteString("name", pet.Name); + + writer.WritePropertyName("photoUrls"); + JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value.Value); + + if (pet.StatusOption.IsSet) + { + var statusRawValue = PetStatusValueConverter.ToJsonValue(pet.Status.Value); + writer.WriteString("status", statusRawValue); + } + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PetStatus.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PetStatus.cs new file mode 100644 index 000000000000..9e19b612bf97 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PetStatus.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// pet status in the store + /// + /// pet status in the store + public enum PetStatus + { + /// + /// Enum Available for value: available + /// + Available = 1, + + /// + /// Enum Pending for value: pending + /// + Pending = 2, + + /// + /// Enum Sold for value: sold + /// + Sold = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class PetStatusValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static PetStatus FromString(string value) + { + if (value.Equals("available")) + return PetStatus.Available; + + if (value.Equals("pending")) + return PetStatus.Pending; + + if (value.Equals("sold")) + return PetStatus.Sold; + + throw new NotImplementedException($"Could not convert value to type PetStatus: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static PetStatus? FromStringOrDefault(string value) + { + if (value.Equals("available")) + return PetStatus.Available; + + if (value.Equals("pending")) + return PetStatus.Pending; + + if (value.Equals("sold")) + return PetStatus.Sold; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(PetStatus value) + { + if (value == PetStatus.Available) + return "available"; + + if (value == PetStatus.Pending) + return "pending"; + + if (value == PetStatus.Sold) + return "sold"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class PetStatusJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override PetStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + PetStatus? result = rawValue == null + ? null + : PetStatusValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the PetStatus to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, PetStatus petStatus, JsonSerializerOptions options) + { + writer.WriteStringValue(petStatus.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class PetStatusNullableJsonConverter : JsonConverter + { + /// + /// Returns a PetStatus from the Json object + /// + /// + /// + /// + /// + public override PetStatus? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + PetStatus? result = rawValue == null + ? null + : PetStatusValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, PetStatus? petStatus, JsonSerializerOptions options) + { + writer.WriteStringValue(petStatus?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs new file mode 100644 index 000000000000..19e395f1de47 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Pig + /// + public partial class Pig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Pig(BasquePig basquePig) + { + BasquePig = basquePig; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Pig(DanishPig danishPig) + { + DanishPig = danishPig; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets BasquePig + /// + public BasquePig BasquePig { get; set; } + + /// + /// Gets or Sets DanishPig + /// + public DanishPig DanishPig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Pig {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + BasquePig basquePig = null; + DanishPig danishPig = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("className")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("BasquePig")) + { + Utf8JsonReader utf8JsonReaderBasquePig = utf8JsonReader; + basquePig = JsonSerializer.Deserialize(ref utf8JsonReaderBasquePig, jsonSerializerOptions); + } + if (discriminator.Equals("DanishPig")) + { + Utf8JsonReader utf8JsonReaderDanishPig = utf8JsonReader; + danishPig = JsonSerializer.Deserialize(ref utf8JsonReaderDanishPig, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); + + if (basquePig != null) + return new Pig(basquePig); + + if (danishPig != null) + return new Pig(danishPig); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (pig.BasquePig != null) { + BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); + } + + if (pig.DanishPig != null) { + DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); + } + + WriteProperties(writer, pig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs new file mode 100644 index 000000000000..30edd0b77d2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -0,0 +1,239 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// PolymorphicProperty + /// + public partial class PolymorphicProperty : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(Object @object) + { + Object = @object; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(List list) + { + List = list; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Object + /// + public Object Object { get; set; } + + /// + /// Gets or Sets List + /// + public List List { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class PolymorphicProperty {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PolymorphicPropertyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override PolymorphicProperty Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + bool? varBool = default; + string varString = default; + Object varObject = default; + List list = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderObject = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject); + + Utf8JsonReader utf8JsonReaderList = utf8JsonReader; + ClientUtils.TryDeserialize>(ref utf8JsonReaderList, jsonSerializerOptions, out list); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (varBool != null) + return new PolymorphicProperty(varBool.Value); + + if (varString != null) + return new PolymorphicProperty(varString); + + if (varObject != null) + return new PolymorphicProperty(varObject); + + if (list != null) + return new PolymorphicProperty(list); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs new file mode 100644 index 000000000000..3d333d7958fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Quadrilateral + /// + public partial class Quadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) + { + SimpleQuadrilateral = simpleQuadrilateral; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) + { + ComplexQuadrilateral = complexQuadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets SimpleQuadrilateral + /// + public SimpleQuadrilateral SimpleQuadrilateral { get; set; } + + /// + /// Gets or Sets ComplexQuadrilateral + /// + public ComplexQuadrilateral ComplexQuadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Quadrilateral {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class QuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + + ComplexQuadrilateral complexQuadrilateral = null; + SimpleQuadrilateral simpleQuadrilateral = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("quadrilateralType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("ComplexQuadrilateral")) + { + Utf8JsonReader utf8JsonReaderComplexQuadrilateral = utf8JsonReader; + complexQuadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderComplexQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("SimpleQuadrilateral")) + { + Utf8JsonReader utf8JsonReaderSimpleQuadrilateral = utf8JsonReader; + simpleQuadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderSimpleQuadrilateral, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); + + if (complexQuadrilateral != null) + return new Quadrilateral(complexQuadrilateral); + + if (simpleQuadrilateral != null) + return new Quadrilateral(simpleQuadrilateral); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (quadrilateral.SimpleQuadrilateral != null) { + SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + } + + if (quadrilateral.ComplexQuadrilateral != null) { + ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, quadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs new file mode 100644 index 000000000000..610005a05408 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// QuadrilateralInterface + /// + public partial class QuadrilateralInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + [JsonConstructor] + public QuadrilateralInterface(string quadrilateralType) + { + QuadrilateralType = quadrilateralType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class QuadrilateralInterface {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class QuadrilateralInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override QuadrilateralInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs new file mode 100644 index 000000000000..87358abb827d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -0,0 +1,241 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ReadOnlyFirst + /// + public partial class ReadOnlyFirst : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar + /// baz + [JsonConstructor] + public ReadOnlyFirst(Option bar = default, Option baz = default) + { + BarOption = bar; + BazOption = baz; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } + + /// + /// Gets or Sets Baz + /// + [JsonPropertyName("baz")] + public string Baz { get { return this.BazOption; } set { this.BazOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ReadOnlyFirst {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Baz: ").Append(Baz).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as ReadOnlyFirst).AreEqual; + } + + /// + /// Returns true if ReadOnlyFirst instances are equal + /// + /// Instance of ReadOnlyFirst to be compared + /// Boolean + public bool Equals(ReadOnlyFirst input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ReadOnlyFirstJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + Option baz = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + case "baz": + baz = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); + + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); + + return new ReadOnlyFirst(bar, baz); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + { + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 000000000000..b708f02a846a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,1335 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredClassRequiredNotnullableEnumInteger requiredNotnullableEnumInteger, RequiredClassRequiredNotnullableEnumIntegerOnly requiredNotnullableEnumIntegerOnly, RequiredClassRequiredNotnullableEnumString requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default, List requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredClassRequiredNullableEnumInteger? requiredNullableEnumInteger = default, RequiredClassRequiredNullableEnumIntegerOnly? requiredNullableEnumIntegerOnly = default, RequiredClassRequiredNullableEnumString? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string requiredNullableStringProp = default, Guid? requiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredClassRequiredNotnullableEnumInteger RequiredNotnullableEnumInteger { get; set; } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredClassRequiredNotnullableEnumIntegerOnly RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredClassRequiredNotnullableEnumString RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public RequiredClassRequiredNotnullableEnumInteger? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public RequiredClassRequiredNotnullableEnumIntegerOnly? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public RequiredClassRequiredNotnullableEnumString? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public RequiredClassRequiredNullableEnumInteger? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public RequiredClassRequiredNullableEnumIntegerOnly? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public RequiredClassRequiredNullableEnumString? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredClassRequiredNullableEnumInteger? RequiredNullableEnumInteger { get; set; } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredClassRequiredNullableEnumIntegerOnly? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredClassRequiredNullableEnumString? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this.NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this.NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this.NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this.NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List NotrequiredNotnullableArrayOfString { get { return this.NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this.NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this.NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string NotrequiredNotnullableStringProp { get { return this.NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this.NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List NotrequiredNullableArrayOfString { get { return this.NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this.NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this.NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string NotrequiredNullableStringProp { get { return this.NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this.NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new Option(value); } } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + Option> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + string requiredNotnullableEnumIntegerRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumIntegerRawValue != null) + requiredNotnullableEnumInteger = new Option(RequiredClassRequiredNotnullableEnumIntegerValueConverter.FromStringOrDefault(requiredNotnullableEnumIntegerRawValue)); + break; + case "required_notnullable_enum_integer_only": + string requiredNotnullableEnumIntegerOnlyRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumIntegerOnlyRawValue != null) + requiredNotnullableEnumIntegerOnly = new Option(RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.FromStringOrDefault(requiredNotnullableEnumIntegerOnlyRawValue)); + break; + case "required_notnullable_enum_string": + string requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClassRequiredNotnullableEnumStringValueConverter.FromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + string notrequiredNotnullableEnumIntegerRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumIntegerRawValue != null) + notrequiredNotnullableEnumInteger = new Option(RequiredClassRequiredNotnullableEnumIntegerValueConverter.FromStringOrDefault(notrequiredNotnullableEnumIntegerRawValue)); + break; + case "notrequired_notnullable_enum_integer_only": + string notrequiredNotnullableEnumIntegerOnlyRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumIntegerOnlyRawValue != null) + notrequiredNotnullableEnumIntegerOnly = new Option(RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.FromStringOrDefault(notrequiredNotnullableEnumIntegerOnlyRawValue)); + break; + case "notrequired_notnullable_enum_string": + string notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClassRequiredNotnullableEnumStringValueConverter.FromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + string notrequiredNullableEnumIntegerRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumIntegerRawValue != null) + notrequiredNullableEnumInteger = new Option(RequiredClassRequiredNullableEnumIntegerValueConverter.FromStringOrDefault(notrequiredNullableEnumIntegerRawValue)); + break; + case "notrequired_nullable_enum_integer_only": + string notrequiredNullableEnumIntegerOnlyRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumIntegerOnlyRawValue != null) + notrequiredNullableEnumIntegerOnly = new Option(RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.FromStringOrDefault(notrequiredNullableEnumIntegerOnlyRawValue)); + break; + case "notrequired_nullable_enum_string": + string notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClassRequiredNullableEnumStringValueConverter.FromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + string requiredNullableEnumIntegerRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumIntegerRawValue != null) + requiredNullableEnumInteger = new Option(RequiredClassRequiredNullableEnumIntegerValueConverter.FromStringOrDefault(requiredNullableEnumIntegerRawValue)); + break; + case "required_nullable_enum_integer_only": + string requiredNullableEnumIntegerOnlyRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumIntegerOnlyRawValue != null) + requiredNullableEnumIntegerOnly = new Option(RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.FromStringOrDefault(requiredNullableEnumIntegerOnlyRawValue)); + break; + case "required_nullable_enum_string": + string requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClassRequiredNullableEnumStringValueConverter.FromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value.Value, requiredNotnullableArrayOfString.Value, requiredNotnullableBooleanProp.Value.Value, requiredNotnullableDatetimeProp.Value.Value, requiredNotnullableEnumInteger.Value.Value, requiredNotnullableEnumIntegerOnly.Value.Value, requiredNotnullableEnumString.Value.Value, requiredNotnullableOuterEnumDefaultValue.Value.Value, requiredNotnullableStringProp.Value, requiredNotnullableUuid.Value.Value, requiredNotnullableintegerProp.Value.Value, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value, requiredNullableBooleanProp.Value, requiredNullableDateProp.Value, requiredNullableDatetimeProp.Value, requiredNullableEnumInteger.Value, requiredNullableEnumIntegerOnly.Value, requiredNullableEnumString.Value, requiredNullableIntegerProp.Value, requiredNullableOuterEnumDefaultValue.Value, requiredNullableStringProp.Value, requiredNullableUuid.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + var requiredNotnullableEnumIntegerRawValue = RequiredClassRequiredNotnullableEnumIntegerValueConverter.ToJsonValue(requiredClass.RequiredNotnullableEnumInteger); + writer.WriteNumber("required_notnullable_enum_integer", requiredNotnullableEnumIntegerRawValue); + + var requiredNotnullableEnumIntegerOnlyRawValue = RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly); + writer.WriteNumber("required_notnullable_enum_integer_only", requiredNotnullableEnumIntegerOnlyRawValue); + + var requiredNotnullableEnumStringRawValue = RequiredClassRequiredNotnullableEnumStringValueConverter.ToJsonValue(requiredClass.RequiredNotnullableEnumString); + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + { + var notrequiredNotnullableEnumIntegerRawValue = RequiredClassRequiredNotnullableEnumIntegerValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableEnumInteger.Value); + writer.WriteNumber("notrequired_notnullable_enum_integer", notrequiredNotnullableEnumIntegerRawValue); + } + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + { + var notrequiredNotnullableEnumIntegerOnlyRawValue = RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnly.Value); + writer.WriteNumber("notrequired_notnullable_enum_integer_only", notrequiredNotnullableEnumIntegerOnlyRawValue); + } + if (requiredClass.NotrequiredNotnullableEnumStringOption.IsSet) + { + var notrequiredNotnullableEnumStringRawValue = RequiredClassRequiredNotnullableEnumStringValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableEnumString.Value); + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + } + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + { + var notrequiredNullableEnumIntegerRawValue = RequiredClassRequiredNullableEnumIntegerValueConverter.ToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value.Value); + writer.WriteNumber("notrequired_nullable_enum_integer", notrequiredNullableEnumIntegerRawValue); + } + else + writer.WriteNull("notrequired_nullable_enum_integer"); + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + { + var notrequiredNullableEnumIntegerOnlyRawValue = RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value.Value); + writer.WriteNumber("notrequired_nullable_enum_integer_only", notrequiredNullableEnumIntegerOnlyRawValue); + } + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + if (requiredClass.NotrequiredNullableEnumStringOption.IsSet) + if (requiredClass.NotrequiredNullableEnumStringOption.Value != null) + { + var notrequiredNullableEnumStringRawValue = RequiredClassRequiredNullableEnumStringValueConverter.ToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value.Value); + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + } + else + writer.WriteNull("notrequired_nullable_enum_string"); + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger == null) + writer.WriteNull("required_nullable_enum_integer"); + else + { + var requiredNullableEnumIntegerRawValue = RequiredClassRequiredNullableEnumIntegerValueConverter.ToJsonValue(requiredClass.RequiredNullableEnumInteger.Value); + writer.WriteNumber("required_nullable_enum_integer", requiredNullableEnumIntegerRawValue); + } + + if (requiredClass.RequiredNullableEnumIntegerOnly == null) + writer.WriteNull("required_nullable_enum_integer_only"); + else + { + var requiredNullableEnumIntegerOnlyRawValue = RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.ToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value); + writer.WriteNumber("required_nullable_enum_integer_only", requiredNullableEnumIntegerOnlyRawValue); + } + + if (requiredClass.RequiredNullableEnumString == null) + writer.WriteNull("required_nullable_enum_string"); + else + { + var requiredNullableEnumStringRawValue = RequiredClassRequiredNullableEnumStringValueConverter.ToJsonValue(requiredClass.RequiredNullableEnumString.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + } + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumInteger.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumInteger.cs new file mode 100644 index 000000000000..04988ef3ee99 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumInteger.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_notnullable_enum_integer + /// + public enum RequiredClassRequiredNotnullableEnumInteger + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNotnullableEnumIntegerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumInteger FromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredClassRequiredNotnullableEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredClassRequiredNotnullableEnumInteger.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNotnullableEnumInteger: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumInteger? FromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredClassRequiredNotnullableEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredClassRequiredNotnullableEnumInteger.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(RequiredClassRequiredNotnullableEnumInteger value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNotnullableEnumIntegerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumInteger? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNotnullableEnumInteger to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumInteger requiredClassRequiredNotnullableEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumInteger.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNotnullableEnumIntegerNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNotnullableEnumInteger from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumInteger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumInteger? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumInteger? requiredClassRequiredNotnullableEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumInteger?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumIntegerOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumIntegerOnly.cs new file mode 100644 index 000000000000..775aba4f6af0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumIntegerOnly.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_notnullable_enum_integer_only + /// + public enum RequiredClassRequiredNotnullableEnumIntegerOnly + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumIntegerOnly FromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredClassRequiredNotnullableEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredClassRequiredNotnullableEnumIntegerOnly.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNotnullableEnumIntegerOnly: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumIntegerOnly? FromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredClassRequiredNotnullableEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredClassRequiredNotnullableEnumIntegerOnly.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(RequiredClassRequiredNotnullableEnumIntegerOnly value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNotnullableEnumIntegerOnlyJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumIntegerOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumIntegerOnly? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNotnullableEnumIntegerOnly to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumIntegerOnly requiredClassRequiredNotnullableEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumIntegerOnly.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNotnullableEnumIntegerOnlyNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNotnullableEnumIntegerOnly from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumIntegerOnly? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumIntegerOnly? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumIntegerOnly? requiredClassRequiredNotnullableEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumIntegerOnly?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs new file mode 100644 index 000000000000..5b4f29294ac6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs @@ -0,0 +1,258 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_notnullable_enum_string + /// + public enum RequiredClassRequiredNotnullableEnumString + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNotnullableEnumStringValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumString FromString(string value) + { + if (value.Equals("UPPER")) + return RequiredClassRequiredNotnullableEnumString.UPPER; + + if (value.Equals("lower")) + return RequiredClassRequiredNotnullableEnumString.Lower; + + if (value.Equals("")) + return RequiredClassRequiredNotnullableEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredClassRequiredNotnullableEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredClassRequiredNotnullableEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredClassRequiredNotnullableEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredClassRequiredNotnullableEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredClassRequiredNotnullableEnumString.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNotnullableEnumString: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNotnullableEnumString? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredClassRequiredNotnullableEnumString.UPPER; + + if (value.Equals("lower")) + return RequiredClassRequiredNotnullableEnumString.Lower; + + if (value.Equals("")) + return RequiredClassRequiredNotnullableEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredClassRequiredNotnullableEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredClassRequiredNotnullableEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredClassRequiredNotnullableEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredClassRequiredNotnullableEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredClassRequiredNotnullableEnumString.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(RequiredClassRequiredNotnullableEnumString value) + { + if (value == RequiredClassRequiredNotnullableEnumString.UPPER) + return "UPPER"; + + if (value == RequiredClassRequiredNotnullableEnumString.Lower) + return "lower"; + + if (value == RequiredClassRequiredNotnullableEnumString.Empty) + return ""; + + if (value == RequiredClassRequiredNotnullableEnumString.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredClassRequiredNotnullableEnumString.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredClassRequiredNotnullableEnumString.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredClassRequiredNotnullableEnumString.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredClassRequiredNotnullableEnumString.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNotnullableEnumStringJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumString? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNotnullableEnumString to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumString requiredClassRequiredNotnullableEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumString.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNotnullableEnumStringNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNotnullableEnumString from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNotnullableEnumString? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNotnullableEnumString? result = rawValue == null + ? null + : RequiredClassRequiredNotnullableEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNotnullableEnumString? requiredClassRequiredNotnullableEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNotnullableEnumString?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs new file mode 100644 index 000000000000..365504a241bf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_nullable_enum_integer + /// + public enum RequiredClassRequiredNullableEnumInteger + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNullableEnumIntegerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumInteger FromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredClassRequiredNullableEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredClassRequiredNullableEnumInteger.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNullableEnumInteger: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumInteger? FromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredClassRequiredNullableEnumInteger.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredClassRequiredNullableEnumInteger.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(RequiredClassRequiredNullableEnumInteger value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNullableEnumIntegerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumInteger? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNullableEnumInteger to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumInteger requiredClassRequiredNullableEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumInteger.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNullableEnumIntegerNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNullableEnumInteger from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumInteger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumInteger? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumInteger? requiredClassRequiredNullableEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumInteger?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs new file mode 100644 index 000000000000..4c5f2c56ba58 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_nullable_enum_integer_only + /// + public enum RequiredClassRequiredNullableEnumIntegerOnly + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNullableEnumIntegerOnlyValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumIntegerOnly FromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredClassRequiredNullableEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredClassRequiredNullableEnumIntegerOnly.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNullableEnumIntegerOnly: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumIntegerOnly? FromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredClassRequiredNullableEnumIntegerOnly.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredClassRequiredNullableEnumIntegerOnly.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(RequiredClassRequiredNullableEnumIntegerOnly value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNullableEnumIntegerOnlyJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumIntegerOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumIntegerOnly? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNullableEnumIntegerOnly to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumIntegerOnly requiredClassRequiredNullableEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumIntegerOnly.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNullableEnumIntegerOnly from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumIntegerOnly? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumIntegerOnly? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumIntegerOnlyValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumIntegerOnly? requiredClassRequiredNullableEnumIntegerOnly, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumIntegerOnly?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs new file mode 100644 index 000000000000..36bcb1481310 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs @@ -0,0 +1,258 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines RequiredClass_required_nullable_enum_string + /// + public enum RequiredClassRequiredNullableEnumString + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Converts to and from the JSON value + /// + public static class RequiredClassRequiredNullableEnumStringValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumString FromString(string value) + { + if (value.Equals("UPPER")) + return RequiredClassRequiredNullableEnumString.UPPER; + + if (value.Equals("lower")) + return RequiredClassRequiredNullableEnumString.Lower; + + if (value.Equals("")) + return RequiredClassRequiredNullableEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredClassRequiredNullableEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredClassRequiredNullableEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredClassRequiredNullableEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredClassRequiredNullableEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredClassRequiredNullableEnumString.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredClassRequiredNullableEnumString: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static RequiredClassRequiredNullableEnumString? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredClassRequiredNullableEnumString.UPPER; + + if (value.Equals("lower")) + return RequiredClassRequiredNullableEnumString.Lower; + + if (value.Equals("")) + return RequiredClassRequiredNullableEnumString.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredClassRequiredNullableEnumString.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredClassRequiredNullableEnumString.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredClassRequiredNullableEnumString.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredClassRequiredNullableEnumString.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredClassRequiredNullableEnumString.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(RequiredClassRequiredNullableEnumString value) + { + if (value == RequiredClassRequiredNullableEnumString.UPPER) + return "UPPER"; + + if (value == RequiredClassRequiredNullableEnumString.Lower) + return "lower"; + + if (value == RequiredClassRequiredNullableEnumString.Empty) + return ""; + + if (value == RequiredClassRequiredNullableEnumString.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredClassRequiredNullableEnumString.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredClassRequiredNullableEnumString.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredClassRequiredNullableEnumString.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredClassRequiredNullableEnumString.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class RequiredClassRequiredNullableEnumStringJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumString? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the RequiredClassRequiredNullableEnumString to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumString requiredClassRequiredNullableEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumString.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassRequiredNullableEnumStringNullableJsonConverter : JsonConverter + { + /// + /// Returns a RequiredClassRequiredNullableEnumString from the Json object + /// + /// + /// + /// + /// + public override RequiredClassRequiredNullableEnumString? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + RequiredClassRequiredNullableEnumString? result = rawValue == null + ? null + : RequiredClassRequiredNullableEnumStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClassRequiredNullableEnumString? requiredClassRequiredNullableEnumString, JsonSerializerOptions options) + { + writer.WriteStringValue(requiredClassRequiredNullableEnumString?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs new file mode 100644 index 000000000000..b294720b3318 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Return.cs @@ -0,0 +1,246 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing reserved words + /// + public partial class Return : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lock + /// abstract + /// varReturn + /// unsafe + [JsonConstructor] + public Return(string @lock, string @abstract = default, Option varReturn = default, Option @unsafe = default) + { + Lock = @lock; + Abstract = @abstract; + VarReturnOption = varReturn; + UnsafeOption = @unsafe; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Lock + /// + [JsonPropertyName("lock")] + public string Lock { get; set; } + + /// + /// Gets or Sets Abstract + /// + [JsonPropertyName("abstract")] + public string Abstract { get; set; } + + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + + /// + /// Gets or Sets VarReturn + /// + [JsonPropertyName("return")] + public int? VarReturn { get { return this.VarReturnOption; } set { this.VarReturnOption = new Option(value); } } + + /// + /// Used to track the state of Unsafe + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsafeOption { get; private set; } + + /// + /// Gets or Sets Unsafe + /// + [JsonPropertyName("unsafe")] + public string Unsafe { get { return this.UnsafeOption; } set { this.UnsafeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Return {\n"); + sb.Append(" Lock: ").Append(Lock).Append("\n"); + sb.Append(" Abstract: ").Append(Abstract).Append("\n"); + sb.Append(" VarReturn: ").Append(VarReturn).Append("\n"); + sb.Append(" Unsafe: ").Append(Unsafe).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ReturnJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varLock = default; + Option varAbstract = default; + Option varReturn = default; + Option varUnsafe = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lock": + varLock = new Option(utf8JsonReader.GetString()); + break; + case "abstract": + varAbstract = new Option(utf8JsonReader.GetString()); + break; + case "return": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varReturn = new Option(utf8JsonReader.GetInt32()); + break; + case "unsafe": + varUnsafe = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!varLock.IsSet) + throw new ArgumentException("Property is required for class Return.", nameof(varLock)); + + if (!varAbstract.IsSet) + throw new ArgumentException("Property is required for class Return.", nameof(varAbstract)); + + if (varLock.IsSet && varLock.Value == null) + throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return."); + + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); + + if (varUnsafe.IsSet && varUnsafe.Value == null) + throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return."); + + return new Return(varLock.Value, varAbstract.Value, varReturn, varUnsafe); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, varReturn, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + { + if (varReturn.Lock == null) + throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return."); + + if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null) + throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return."); + + writer.WriteString("lock", varReturn.Lock); + + if (varReturn.Abstract != null) + writer.WriteString("abstract", varReturn.Abstract); + else + writer.WriteNull("abstract"); + + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value.Value); + + if (varReturn.UnsafeOption.IsSet) + writer.WriteString("unsafe", varReturn.Unsafe); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs new file mode 100644 index 000000000000..494ee791a242 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -0,0 +1,204 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Role report Hash + /// + public partial class RolesReportsHash : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// role + /// roleUuid + [JsonConstructor] + public RolesReportsHash(Option role = default, Option roleUuid = default) + { + RoleOption = role; + RoleUuidOption = roleUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + + /// + /// Gets or Sets Role + /// + [JsonPropertyName("role")] + public RolesReportsHashRole Role { get { return this.RoleOption; } set { this.RoleOption = new Option(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } + + /// + /// Gets or Sets RoleUuid + /// + [JsonPropertyName("role_uuid")] + public Guid? RoleUuid { get { return this.RoleUuidOption; } set { this.RoleUuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RolesReportsHash {\n"); + sb.Append(" Role: ").Append(Role).Append("\n"); + sb.Append(" RoleUuid: ").Append(RoleUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RolesReportsHashJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option role = default; + Option roleUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "role": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "role_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + roleUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); + + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); + + return new RolesReportsHash(role, roleUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + { + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs new file mode 100644 index 000000000000..4d0df8c9fc49 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RolesReportsHashRole + /// + public partial class RolesReportsHashRole : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public RolesReportsHashRole(Option name = default) + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RolesReportsHashRole {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RolesReportsHashRoleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); + + return new RolesReportsHashRole(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + { + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs new file mode 100644 index 000000000000..47081ede38ef --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ScaleneTriangle + /// + public partial class ScaleneTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public ScaleneTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ScaleneTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ScaleneTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ScaleneTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + + writer.WriteString("triangleType", scaleneTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs new file mode 100644 index 000000000000..d4883a363a21 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Shape + /// + public partial class Shape : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Shape(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Shape(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Shape {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); + + if (quadrilateral != null) + return new Shape(quadrilateral); + + if (triangle != null) + return new Shape(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (shape.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); + } + + if (shape.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, shape, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs new file mode 100644 index 000000000000..3027d9142baf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ShapeInterface + /// + public partial class ShapeInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + [JsonConstructor] + public ShapeInterface(string shapeType) + { + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ShapeInterface {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ShapeInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, shapeInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + + writer.WriteString("shapeType", shapeInterface.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs new file mode 100644 index 000000000000..2d9fb2cbb334 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + /// + public partial class ShapeOrNull : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public ShapeOrNull(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public ShapeOrNull(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ShapeOrNull {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeOrNullJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); + + if (quadrilateral != null) + return new ShapeOrNull(quadrilateral); + + if (triangle != null) + return new ShapeOrNull(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (shapeOrNull.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); + } + + if (shapeOrNull.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs new file mode 100644 index 000000000000..3fa8bdc19177 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// SimpleQuadrilateral + /// + public partial class SimpleQuadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + /// shapeType + [JsonConstructor] + public SimpleQuadrilateral(string quadrilateralType, string shapeType) + { + QuadrilateralType = quadrilateralType; + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class SimpleQuadrilateral {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class SimpleQuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override SimpleQuadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value, shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs new file mode 100644 index 000000000000..9b44556fcb0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// SpecialModelName + /// + public partial class SpecialModelName : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varSpecialModelName + /// specialPropertyName + [JsonConstructor] + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) + { + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + + /// + /// Gets or Sets VarSpecialModelName + /// + [JsonPropertyName("_special_model.name_")] + public string VarSpecialModelName { get { return this.VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new Option(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } + + /// + /// Gets or Sets SpecialPropertyName + /// + [JsonPropertyName("$special[property.name]")] + public long? SpecialPropertyName { get { return this.SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class SpecialModelName {\n"); + sb.Append(" VarSpecialModelName: ").Append(VarSpecialModelName).Append("\n"); + sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class SpecialModelNameJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varSpecialModelName = default; + Option specialPropertyName = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "_special_model.name_": + varSpecialModelName = new Option(utf8JsonReader.GetString()); + break; + case "$special[property.name]": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + specialPropertyName = new Option(utf8JsonReader.GetInt64()); + break; + default: + break; + } + } + } + + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); + + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); + + return new SpecialModelName(varSpecialModelName, specialPropertyName); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, specialModelName, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + { + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs new file mode 100644 index 000000000000..91ee6000335a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Tag.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Tag + /// + public partial class Tag : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + /// name + [JsonConstructor] + public Tag(Option id = default, Option name = default) + { + IdOption = id; + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TagJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option id = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); + + return new Tag(id, name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, tag, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + { + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs new file mode 100644 index 000000000000..1821b112bfb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestCollectionEndingWithWordList + /// + public partial class TestCollectionEndingWithWordList : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// value + [JsonConstructor] + public TestCollectionEndingWithWordList(Option value = default) + { + ValueOption = value; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + + /// + /// Gets or Sets Value + /// + [JsonPropertyName("value")] + public string Value { get { return this.ValueOption; } set { this.ValueOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestCollectionEndingWithWordList {\n"); + sb.Append(" Value: ").Append(Value).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestCollectionEndingWithWordListJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option value = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "value": + value = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); + + return new TestCollectionEndingWithWordList(value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + { + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs new file mode 100644 index 000000000000..433bfa41bae1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestCollectionEndingWithWordListObject + /// + public partial class TestCollectionEndingWithWordListObject : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// testCollectionEndingWithWordList + [JsonConstructor] + public TestCollectionEndingWithWordListObject(Option> testCollectionEndingWithWordList = default) + { + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TestCollectionEndingWithWordListOption { get; private set; } + + /// + /// Gets or Sets TestCollectionEndingWithWordList + /// + [JsonPropertyName("TestCollectionEndingWithWordList")] + public List TestCollectionEndingWithWordList { get { return this.TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestCollectionEndingWithWordListObject {\n"); + sb.Append(" TestCollectionEndingWithWordList: ").Append(TestCollectionEndingWithWordList).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestCollectionEndingWithWordListObjectJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> testCollectionEndingWithWordList = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "TestCollectionEndingWithWordList": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + testCollectionEndingWithWordList = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); + + return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + { + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumHeaderStringParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumHeaderStringParameter.cs new file mode 100644 index 000000000000..ccb446b02503 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumHeaderStringParameter.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines testEnumParameters_enum_header_string_parameter + /// + public enum TestEnumParametersEnumHeaderStringParameter + { + /// + /// Enum Abc for value: _abc + /// + Abc = 1, + + /// + /// Enum Efg for value: -efg + /// + Efg = 2, + + /// + /// Enum Xyz for value: (xyz) + /// + Xyz = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestEnumParametersEnumHeaderStringParameterValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumHeaderStringParameter FromString(string value) + { + if (value.Equals("_abc")) + return TestEnumParametersEnumHeaderStringParameter.Abc; + + if (value.Equals("-efg")) + return TestEnumParametersEnumHeaderStringParameter.Efg; + + if (value.Equals("(xyz)")) + return TestEnumParametersEnumHeaderStringParameter.Xyz; + + throw new NotImplementedException($"Could not convert value to type TestEnumParametersEnumHeaderStringParameter: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumHeaderStringParameter? FromStringOrDefault(string value) + { + if (value.Equals("_abc")) + return TestEnumParametersEnumHeaderStringParameter.Abc; + + if (value.Equals("-efg")) + return TestEnumParametersEnumHeaderStringParameter.Efg; + + if (value.Equals("(xyz)")) + return TestEnumParametersEnumHeaderStringParameter.Xyz; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestEnumParametersEnumHeaderStringParameter value) + { + if (value == TestEnumParametersEnumHeaderStringParameter.Abc) + return "_abc"; + + if (value == TestEnumParametersEnumHeaderStringParameter.Efg) + return "-efg"; + + if (value == TestEnumParametersEnumHeaderStringParameter.Xyz) + return "(xyz)"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestEnumParametersEnumHeaderStringParameterJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumHeaderStringParameter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumHeaderStringParameter? result = rawValue == null + ? null + : TestEnumParametersEnumHeaderStringParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestEnumParametersEnumHeaderStringParameter to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumHeaderStringParameter testEnumParametersEnumHeaderStringParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumHeaderStringParameter.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestEnumParametersEnumHeaderStringParameterNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestEnumParametersEnumHeaderStringParameter from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumHeaderStringParameter? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumHeaderStringParameter? result = rawValue == null + ? null + : TestEnumParametersEnumHeaderStringParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumHeaderStringParameter? testEnumParametersEnumHeaderStringParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumHeaderStringParameter?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryDoubleParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryDoubleParameter.cs new file mode 100644 index 000000000000..ec14b39944da --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryDoubleParameter.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines testEnumParameters_enum_query_double_parameter + /// + public enum TestEnumParametersEnumQueryDoubleParameter + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestEnumParametersEnumQueryDoubleParameterValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumQueryDoubleParameter FromString(string value) + { + if (value.Equals("1.1")) + return TestEnumParametersEnumQueryDoubleParameter.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return TestEnumParametersEnumQueryDoubleParameter.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type TestEnumParametersEnumQueryDoubleParameter: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumQueryDoubleParameter? FromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return TestEnumParametersEnumQueryDoubleParameter.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return TestEnumParametersEnumQueryDoubleParameter.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double ToJsonValue(TestEnumParametersEnumQueryDoubleParameter value) + { + return (double) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class TestEnumParametersEnumQueryDoubleParameterJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumQueryDoubleParameter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumQueryDoubleParameter? result = rawValue == null + ? null + : TestEnumParametersEnumQueryDoubleParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestEnumParametersEnumQueryDoubleParameter to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumQueryDoubleParameter testEnumParametersEnumQueryDoubleParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumQueryDoubleParameter.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestEnumParametersEnumQueryDoubleParameterNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestEnumParametersEnumQueryDoubleParameter from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumQueryDoubleParameter? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumQueryDoubleParameter? result = rawValue == null + ? null + : TestEnumParametersEnumQueryDoubleParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumQueryDoubleParameter? testEnumParametersEnumQueryDoubleParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumQueryDoubleParameter?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs new file mode 100644 index 000000000000..33ff2ce2cc21 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs @@ -0,0 +1,168 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines testEnumParameters_enum_query_integer_parameter + /// + public enum TestEnumParametersEnumQueryIntegerParameter + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestEnumParametersEnumQueryIntegerParameterValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumQueryIntegerParameter FromString(string value) + { + if (value.Equals((1).ToString())) + return TestEnumParametersEnumQueryIntegerParameter.NUMBER_1; + + if (value.Equals((-2).ToString())) + return TestEnumParametersEnumQueryIntegerParameter.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type TestEnumParametersEnumQueryIntegerParameter: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersEnumQueryIntegerParameter? FromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return TestEnumParametersEnumQueryIntegerParameter.NUMBER_1; + + if (value.Equals((-2).ToString())) + return TestEnumParametersEnumQueryIntegerParameter.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(TestEnumParametersEnumQueryIntegerParameter value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class TestEnumParametersEnumQueryIntegerParameterJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumQueryIntegerParameter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumQueryIntegerParameter? result = rawValue == null + ? null + : TestEnumParametersEnumQueryIntegerParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestEnumParametersEnumQueryIntegerParameter to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumQueryIntegerParameter testEnumParametersEnumQueryIntegerParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumQueryIntegerParameter.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestEnumParametersEnumQueryIntegerParameterNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestEnumParametersEnumQueryIntegerParameter from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersEnumQueryIntegerParameter? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersEnumQueryIntegerParameter? result = rawValue == null + ? null + : TestEnumParametersEnumQueryIntegerParameterValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersEnumQueryIntegerParameter? testEnumParametersEnumQueryIntegerParameter, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersEnumQueryIntegerParameter?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs new file mode 100644 index 000000000000..d86b48d4a9b7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Form parameter enum test (string) + /// + /// Form parameter enum test (string) + public enum TestEnumParametersRequestEnumFormString + { + /// + /// Enum Abc for value: _abc + /// + Abc = 1, + + /// + /// Enum Efg for value: -efg + /// + Efg = 2, + + /// + /// Enum Xyz for value: (xyz) + /// + Xyz = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestEnumParametersRequestEnumFormStringValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersRequestEnumFormString FromString(string value) + { + if (value.Equals("_abc")) + return TestEnumParametersRequestEnumFormString.Abc; + + if (value.Equals("-efg")) + return TestEnumParametersRequestEnumFormString.Efg; + + if (value.Equals("(xyz)")) + return TestEnumParametersRequestEnumFormString.Xyz; + + throw new NotImplementedException($"Could not convert value to type TestEnumParametersRequestEnumFormString: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersRequestEnumFormString? FromStringOrDefault(string value) + { + if (value.Equals("_abc")) + return TestEnumParametersRequestEnumFormString.Abc; + + if (value.Equals("-efg")) + return TestEnumParametersRequestEnumFormString.Efg; + + if (value.Equals("(xyz)")) + return TestEnumParametersRequestEnumFormString.Xyz; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestEnumParametersRequestEnumFormString value) + { + if (value == TestEnumParametersRequestEnumFormString.Abc) + return "_abc"; + + if (value == TestEnumParametersRequestEnumFormString.Efg) + return "-efg"; + + if (value == TestEnumParametersRequestEnumFormString.Xyz) + return "(xyz)"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestEnumParametersRequestEnumFormStringJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersRequestEnumFormString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersRequestEnumFormString? result = rawValue == null + ? null + : TestEnumParametersRequestEnumFormStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestEnumParametersRequestEnumFormString to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersRequestEnumFormString testEnumParametersRequestEnumFormString, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersRequestEnumFormString.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestEnumParametersRequestEnumFormStringNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestEnumParametersRequestEnumFormString from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersRequestEnumFormString? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersRequestEnumFormString? result = rawValue == null + ? null + : TestEnumParametersRequestEnumFormStringValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersRequestEnumFormString? testEnumParametersRequestEnumFormString, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersRequestEnumFormString?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs new file mode 100644 index 000000000000..4f1c9c53c603 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines testEnumParameters_request_enum_form_string_array_inner + /// + public enum TestEnumParametersRequestEnumFormStringArrayInner + { + /// + /// Enum GreaterThan for value: > + /// + GreaterThan = 1, + + /// + /// Enum Dollar for value: $ + /// + Dollar = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestEnumParametersRequestEnumFormStringArrayInnerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersRequestEnumFormStringArrayInner FromString(string value) + { + if (value.Equals(">")) + return TestEnumParametersRequestEnumFormStringArrayInner.GreaterThan; + + if (value.Equals("$")) + return TestEnumParametersRequestEnumFormStringArrayInner.Dollar; + + throw new NotImplementedException($"Could not convert value to type TestEnumParametersRequestEnumFormStringArrayInner: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestEnumParametersRequestEnumFormStringArrayInner? FromStringOrDefault(string value) + { + if (value.Equals(">")) + return TestEnumParametersRequestEnumFormStringArrayInner.GreaterThan; + + if (value.Equals("$")) + return TestEnumParametersRequestEnumFormStringArrayInner.Dollar; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestEnumParametersRequestEnumFormStringArrayInner value) + { + if (value == TestEnumParametersRequestEnumFormStringArrayInner.GreaterThan) + return ">"; + + if (value == TestEnumParametersRequestEnumFormStringArrayInner.Dollar) + return "$"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersRequestEnumFormStringArrayInner Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersRequestEnumFormStringArrayInner? result = rawValue == null + ? null + : TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestEnumParametersRequestEnumFormStringArrayInner to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersRequestEnumFormStringArrayInner.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestEnumParametersRequestEnumFormStringArrayInner from the Json object + /// + /// + /// + /// + /// + public override TestEnumParametersRequestEnumFormStringArrayInner? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestEnumParametersRequestEnumFormStringArrayInner? result = rawValue == null + ? null + : TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestEnumParametersRequestEnumFormStringArrayInner? testEnumParametersRequestEnumFormStringArrayInner, JsonSerializerOptions options) + { + writer.WriteStringValue(testEnumParametersRequestEnumFormStringArrayInner?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs new file mode 100644 index 000000000000..1cb26beb9347 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestInlineFreeformAdditionalPropertiesRequest + /// + public partial class TestInlineFreeformAdditionalPropertiesRequest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// someProperty + [JsonConstructor] + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) + { + SomePropertyOption = someProperty; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + + /// + /// Gets or Sets SomeProperty + /// + [JsonPropertyName("someProperty")] + public string SomeProperty { get { return this.SomePropertyOption; } set { this.SomePropertyOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestInlineFreeformAdditionalPropertiesRequest {\n"); + sb.Append(" SomeProperty: ").Append(SomeProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestInlineFreeformAdditionalPropertiesRequestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option someProperty = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "someProperty": + someProperty = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); + + return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + { + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs new file mode 100644 index 000000000000..d31d2948c652 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs @@ -0,0 +1,266 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Triangle + /// + public partial class Triangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(EquilateralTriangle equilateralTriangle) + { + EquilateralTriangle = equilateralTriangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(IsoscelesTriangle isoscelesTriangle) + { + IsoscelesTriangle = isoscelesTriangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(ScaleneTriangle scaleneTriangle) + { + ScaleneTriangle = scaleneTriangle; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets EquilateralTriangle + /// + public EquilateralTriangle EquilateralTriangle { get; set; } + + /// + /// Gets or Sets IsoscelesTriangle + /// + public IsoscelesTriangle IsoscelesTriangle { get; set; } + + /// + /// Gets or Sets ScaleneTriangle + /// + public ScaleneTriangle ScaleneTriangle { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Triangle {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option triangleType = default; + + EquilateralTriangle equilateralTriangle = null; + IsoscelesTriangle isoscelesTriangle = null; + ScaleneTriangle scaleneTriangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("triangleType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("EquilateralTriangle")) + { + Utf8JsonReader utf8JsonReaderEquilateralTriangle = utf8JsonReader; + equilateralTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderEquilateralTriangle, jsonSerializerOptions); + } + if (discriminator.Equals("IsoscelesTriangle")) + { + Utf8JsonReader utf8JsonReaderIsoscelesTriangle = utf8JsonReader; + isoscelesTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderIsoscelesTriangle, jsonSerializerOptions); + } + if (discriminator.Equals("ScaleneTriangle")) + { + Utf8JsonReader utf8JsonReaderScaleneTriangle = utf8JsonReader; + scaleneTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderScaleneTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); + + if (equilateralTriangle != null) + return new Triangle(equilateralTriangle); + + if (isoscelesTriangle != null) + return new Triangle(isoscelesTriangle); + + if (scaleneTriangle != null) + return new Triangle(scaleneTriangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (triangle.EquilateralTriangle != null) { + EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); + } + + if (triangle.IsoscelesTriangle != null) { + IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + } + + if (triangle.ScaleneTriangle != null) { + ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); + } + + WriteProperties(writer, triangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs new file mode 100644 index 000000000000..aa6d31b91909 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TriangleInterface + /// + public partial class TriangleInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// triangleType + [JsonConstructor] + public TriangleInterface(string triangleType) + { + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TriangleInterface {\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TriangleInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TriangleInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, triangleInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + + writer.WriteString("triangleType", triangleInterface.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs new file mode 100644 index 000000000000..a2f3e4a18a69 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/User.cs @@ -0,0 +1,497 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// User + /// + public partial class User : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + /// email + /// firstName + /// id + /// lastName + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// password + /// phone + /// User Status + /// username + [JsonConstructor] + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) + { + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of AnyTypeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } + + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + [JsonPropertyName("anyTypeProp")] + public Object AnyTypeProp { get { return this.AnyTypePropOption; } set { this.AnyTypePropOption = new Option(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } + + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + [JsonPropertyName("anyTypePropNullable")] + public Object AnyTypePropNullable { get { return this.AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new Option(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string Email { get { return this.EmailOption; } set { this.EmailOption = new Option(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string FirstName { get { return this.FirstNameOption; } set { this.FirstNameOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string LastName { get { return this.LastNameOption; } set { this.LastNameOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object ObjectWithNoDeclaredProps { get { return this.ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } + + /// + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + [JsonPropertyName("objectWithNoDeclaredPropsNullable")] + public Object ObjectWithNoDeclaredPropsNullable { get { return this.ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new Option(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get { return this.PasswordOption; } set { this.PasswordOption = new Option(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string Phone { get { return this.PhoneOption; } set { this.PhoneOption = new Option(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this.UserStatusOption; } set { this.UserStatusOption = new Option(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string Username { get { return this.UsernameOption; } set { this.UsernameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).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(" Username: ").Append(Username).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class UserJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "anyTypeProp": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "anyTypePropNullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "objectWithNoDeclaredPropsNullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); + + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); + + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); + + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); + + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); + + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); + + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); + + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, user, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + { + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs new file mode 100644 index 000000000000..b93046c5457b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Whale.cs @@ -0,0 +1,223 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Whale + /// + public partial class Whale : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + /// hasBaleen + /// hasTeeth + [JsonConstructor] + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) + { + ClassName = className; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + + /// + /// Gets or Sets HasBaleen + /// + [JsonPropertyName("hasBaleen")] + public bool? HasBaleen { get { return this.HasBaleenOption; } set { this.HasBaleenOption = new Option(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } + + /// + /// Gets or Sets HasTeeth + /// + [JsonPropertyName("hasTeeth")] + public bool? HasTeeth { get { return this.HasTeethOption; } set { this.HasTeethOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Whale {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" HasBaleen: ").Append(HasBaleen).Append("\n"); + sb.Append(" HasTeeth: ").Append(HasTeeth).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class WhaleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "hasBaleen": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + hasBaleen = new Option(utf8JsonReader.GetBoolean()); + break; + case "hasTeeth": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + hasTeeth = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); + + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); + + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value, hasBaleen, hasTeeth); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, whale, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + + writer.WriteString("className", whale.ClassName); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs new file mode 100644 index 000000000000..05a3f11aff3e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Zebra.cs @@ -0,0 +1,200 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Zebra + /// + public partial class Zebra : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + /// type + [JsonConstructor] + public Zebra(string className, Option type = default) + { + ClassName = className; + TypeOption = type; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + + /// + /// Gets or Sets Type + /// + [JsonPropertyName("type")] + public ZebraType? Type { get { return this.TypeOption; } set { this.TypeOption = new Option(value); } } + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Zebra {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ZebraJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option type = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "type": + string typeRawValue = utf8JsonReader.GetString(); + if (typeRawValue != null) + type = new Option(ZebraTypeValueConverter.FromStringOrDefault(typeRawValue)); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value, type); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, zebra, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + + writer.WriteString("className", zebra.ClassName); + + if (zebra.TypeOption.IsSet) + { + var typeRawValue = ZebraTypeValueConverter.ToJsonValue(zebra.Type.Value); + writer.WriteString("type", typeRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZebraType.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZebraType.cs new file mode 100644 index 000000000000..4a54f2a265a1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZebraType.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines zebra_type + /// + public enum ZebraType + { + /// + /// Enum Plains for value: plains + /// + Plains = 1, + + /// + /// Enum Mountain for value: mountain + /// + Mountain = 2, + + /// + /// Enum Grevys for value: grevys + /// + Grevys = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class ZebraTypeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static ZebraType FromString(string value) + { + if (value.Equals("plains")) + return ZebraType.Plains; + + if (value.Equals("mountain")) + return ZebraType.Mountain; + + if (value.Equals("grevys")) + return ZebraType.Grevys; + + throw new NotImplementedException($"Could not convert value to type ZebraType: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static ZebraType? FromStringOrDefault(string value) + { + if (value.Equals("plains")) + return ZebraType.Plains; + + if (value.Equals("mountain")) + return ZebraType.Mountain; + + if (value.Equals("grevys")) + return ZebraType.Grevys; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(ZebraType value) + { + if (value == ZebraType.Plains) + return "plains"; + + if (value == ZebraType.Mountain) + return "mountain"; + + if (value == ZebraType.Grevys) + return "grevys"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class ZebraTypeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override ZebraType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZebraType? result = rawValue == null + ? null + : ZebraTypeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the ZebraType to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZebraType zebraType, JsonSerializerOptions options) + { + writer.WriteStringValue(zebraType.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class ZebraTypeNullableJsonConverter : JsonConverter + { + /// + /// Returns a ZebraType from the Json object + /// + /// + /// + /// + /// + public override ZebraType? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZebraType? result = rawValue == null + ? null + : ZebraTypeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZebraType? zebraType, JsonSerializerOptions options) + { + writer.WriteStringValue(zebraType?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs new file mode 100644 index 000000000000..34a044fb8b13 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines ZeroBasedEnum + /// + public enum ZeroBasedEnum + { + /// + /// Enum Unknown for value: unknown + /// + Unknown, + + /// + /// Enum NotUnknown for value: notUnknown + /// + NotUnknown + } + + /// + /// Converts to and from the JSON value + /// + public static class ZeroBasedEnumValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnum FromString(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnum.NotUnknown; + + throw new NotImplementedException($"Could not convert value to type ZeroBasedEnum: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnum? FromStringOrDefault(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnum.NotUnknown; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(ZeroBasedEnum value) + { + if (value == ZeroBasedEnum.Unknown) + return "unknown"; + + if (value == ZeroBasedEnum.NotUnknown) + return "notUnknown"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class ZeroBasedEnumJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the ZeroBasedEnum to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnum zeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnum.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class ZeroBasedEnumNullableJsonConverter : JsonConverter + { + /// + /// Returns a ZeroBasedEnum from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnum? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnum? zeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnum?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs new file mode 100644 index 000000000000..890d16a7d5be --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -0,0 +1,176 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ZeroBasedEnumClass + /// + public partial class ZeroBasedEnumClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// zeroBasedEnum + [JsonConstructor] + public ZeroBasedEnumClass(Option zeroBasedEnum = default) + { + ZeroBasedEnumOption = zeroBasedEnum; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + + /// + /// Gets or Sets ZeroBasedEnum + /// + [JsonPropertyName("ZeroBasedEnum")] + public ZeroBasedEnumClassZeroBasedEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ZeroBasedEnumClass {\n"); + sb.Append(" ZeroBasedEnum: ").Append(ZeroBasedEnum).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ZeroBasedEnumClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option zeroBasedEnum = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ZeroBasedEnum": + string zeroBasedEnumRawValue = utf8JsonReader.GetString(); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClassZeroBasedEnumValueConverter.FromStringOrDefault(zeroBasedEnumRawValue)); + break; + default: + break; + } + } + } + + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); + + return new ZeroBasedEnumClass(zeroBasedEnum); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + { + if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet) + { + var zeroBasedEnumRawValue = ZeroBasedEnumClassZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnumClass.ZeroBasedEnum.Value); + writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClassZeroBasedEnum.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClassZeroBasedEnum.cs new file mode 100644 index 000000000000..2b062a550aba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClassZeroBasedEnum.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines ZeroBasedEnumClass_ZeroBasedEnum + /// + public enum ZeroBasedEnumClassZeroBasedEnum + { + /// + /// Enum Unknown for value: unknown + /// + Unknown, + + /// + /// Enum NotUnknown for value: notUnknown + /// + NotUnknown + } + + /// + /// Converts to and from the JSON value + /// + public static class ZeroBasedEnumClassZeroBasedEnumValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnumClassZeroBasedEnum FromString(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnumClassZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnumClassZeroBasedEnum.NotUnknown; + + throw new NotImplementedException($"Could not convert value to type ZeroBasedEnumClassZeroBasedEnum: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnumClassZeroBasedEnum? FromStringOrDefault(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnumClassZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnumClassZeroBasedEnum.NotUnknown; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(ZeroBasedEnumClassZeroBasedEnum value) + { + if (value == ZeroBasedEnumClassZeroBasedEnum.Unknown) + return "unknown"; + + if (value == ZeroBasedEnumClassZeroBasedEnum.NotUnknown) + return "notUnknown"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class ZeroBasedEnumClassZeroBasedEnumJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnumClassZeroBasedEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnumClassZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumClassZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the ZeroBasedEnumClassZeroBasedEnum to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClassZeroBasedEnum zeroBasedEnumClassZeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnumClassZeroBasedEnum.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class ZeroBasedEnumClassZeroBasedEnumNullableJsonConverter : JsonConverter + { + /// + /// Returns a ZeroBasedEnumClassZeroBasedEnum from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnumClassZeroBasedEnum? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnumClassZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumClassZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClassZeroBasedEnum? zeroBasedEnumClassZeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnumClassZeroBasedEnum?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..c6529e054024 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,33 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..bd9faa467e44 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/README.md @@ -0,0 +1,223 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + Call123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo"); + ModelClient model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + // the type of token here depends on the api security specifications + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); + options.AddTokens(token); + + // optionally choose the method the tokens will be provided with, default is RateLimitProvider + options.UseProvider, ApiKeyToken>(); + + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: +- write:pets: modify pets in your account +- read:pets: read your pets + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +### http_basic_test + +- **Type**: HTTP basic authentication + + +### bearer_test + +- **Type**: Bearer Authentication + + +### http_signature_test + +- **Type**: HTTP signature authentication + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: OpenAPI Petstore +- appVersion: 1.0.0 +- appDescription: This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.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/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.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/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES new file mode 100644 index 000000000000..59cc1ea25a08 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/FILES @@ -0,0 +1,40 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/DefaultApi.md +docs/models/Apple.md +docs/models/Banana.md +docs/models/Fruit.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Apple.cs +src/Org.OpenAPITools/Model/Banana.cs +src/Org.OpenAPITools/Model/Fruit.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/OneOf/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/README.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/OneOf/api/openapi.yaml new file mode 100644 index 000000000000..06fd58be740a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/api/openapi.yaml @@ -0,0 +1,41 @@ +openapi: 3.0.1 +info: + title: fruity + version: 0.0.1 +servers: +- url: / +paths: + /: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/fruit' + description: desc +components: + schemas: + fruit: + example: + color: color + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + title: fruit + apple: + properties: + kind: + type: string + title: apple + type: object + banana: + properties: + count: + type: number + title: banana + type: object + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/OneOf/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..bccf3af9c516 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/apis/DefaultApi.md @@ -0,0 +1,90 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**RootGet**](DefaultApi.md#rootget) | **GET** / | | + + +# **RootGet** +> Fruit RootGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class RootGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://localhost"; + var apiInstance = new DefaultApi(config); + + try + { + Fruit result = apiInstance.RootGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.RootGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the RootGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.RootGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.RootGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**Fruit**](Fruit.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | desc | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Apple.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Apple.md new file mode 100644 index 000000000000..95f575834399 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Apple.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Kind** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Banana.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Banana.md new file mode 100644 index 000000000000..c9aea6fb56c8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Banana.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Count** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Fruit.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Fruit.md new file mode 100644 index 000000000000..b3bee18f7ba0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/models/Fruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..5a82cd6c99de --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,58 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..b7bcc281037a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,64 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test RootGet + /// + [Fact (Skip = "not implemented")] + public async Task RootGetAsyncTest() + { + var response = await _instance.RootGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..c9833ec353ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,103 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs new file mode 100644 index 000000000000..483628b6a4a0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/AppleTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Apple + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Apple + //private Apple instance; + + public AppleTests() + { + // TODO uncomment below to create an instance of Apple + //instance = new Apple(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Apple + /// + [Fact] + public void AppleInstanceTest() + { + // TODO uncomment below to test "IsType" Apple + //Assert.IsType(instance); + } + + /// + /// Test the property 'Kind' + /// + [Fact] + public void KindTest() + { + // TODO unit test for the property 'Kind' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs new file mode 100644 index 000000000000..5befec8d7e5f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/BananaTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Banana + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Banana + //private Banana instance; + + public BananaTests() + { + // TODO uncomment below to create an instance of Banana + //instance = new Banana(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Banana + /// + [Fact] + public void BananaInstanceTest() + { + // TODO uncomment below to test "IsType" Banana + //Assert.IsType(instance); + } + + /// + /// Test the property 'Count' + /// + [Fact] + public void CountTest() + { + // TODO unit test for the property 'Count' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs new file mode 100644 index 000000000000..a6607ae5d56d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -0,0 +1,65 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Fruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Fruit + //private Fruit instance; + + public FruitTests() + { + // TODO uncomment below to create an instance of Fruit + //instance = new Fruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Fruit + /// + [Fact] + public void FruitInstanceTest() + { + // TODO uncomment below to test "IsType" Fruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..8ea8bdbe84e9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,329 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IRootGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnRootGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorRootGet; + + internal void ExecuteOnRootGet(DefaultApi.RootGetApiResponse apiResponse) + { + OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorRootGet(Exception exception) + { + OnErrorRootGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + } + + /// + /// Processes the server response + /// + /// + private void AfterRootGetDefaultImplementation(IRootGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterRootGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterRootGet(ref bool suppressDefaultLog, IRootGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorRootGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorRootGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorRootGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await RootGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task RootGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + RootGetApiResponse apiResponseLocalVar = new RootGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions); + + AfterRootGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnRootGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorRootGetDefaultImplementation(e, "/", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRootGet(e); + throw; + } + } + + /// + /// The + /// + public partial class RootGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRootGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public RootGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Fruit Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Fruit result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..1d43e69742f6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..de1f5521df66 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,170 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..91e5f4c09c08 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,329 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using KellermanSoftware.CompareNetObjects; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static constructor to initialise compareLogic. + /// + static ClientUtils() + { + ComparisonConfig comparisonConfig = new ComparisonConfig(); + comparisonConfig.UseHashCodeIdentifier = true; + compareLogic = new CompareLogic(comparisonConfig); + } + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://localhost"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = ""; + + /// + /// The host of the API + /// + public const string HOST = "localhost"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..68e90f4ecbb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..3cb4b6ce51e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..a90199eebd63 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,131 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new AppleJsonConverter()); + _jsonOptions.Converters.Add(new BananaJsonConverter()); + _jsonOptions.Converters.Add(new FruitJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..55d56f3f2049 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..8e7bed46e9c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,55 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..3924246ab7c2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..df405f3894d4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,57 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..e1dec11976d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..2e27cceb8d12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static void AddApi(this IServiceCollection services) + { + HostConfiguration config = new HostConfiguration(services); + AddApi(services, config); + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs new file mode 100644 index 000000000000..dad28e7397be --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Apple.cs @@ -0,0 +1,174 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Apple + /// + public partial class Apple : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// kind + [JsonConstructor] + public Apple(Option kind = default) + { + KindOption = kind; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Kind + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option KindOption { get; private set; } + + /// + /// Gets or Sets Kind + /// + [JsonPropertyName("kind")] + public string Kind { get { return this.KindOption; } set { this.KindOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Apple {\n"); + sb.Append(" Kind: ").Append(Kind).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option kind = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "kind": + kind = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (kind.IsSet && kind.Value == null) + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); + + return new Apple(kind); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apple, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + if (apple.KindOption.IsSet && apple.Kind == null) + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); + + if (apple.KindOption.IsSet) + writer.WriteString("kind", apple.Kind); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs new file mode 100644 index 000000000000..3041dedf17d3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Banana.cs @@ -0,0 +1,172 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Banana + /// + public partial class Banana : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// count + [JsonConstructor] + public Banana(Option count = default) + { + CountOption = count; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Count + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountOption { get; private set; } + + /// + /// Gets or Sets Count + /// + [JsonPropertyName("count")] + public decimal? Count { get { return this.CountOption; } set { this.CountOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Banana {\n"); + sb.Append(" Count: ").Append(Count).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option count = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "count": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + count = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (count.IsSet && count.Value == null) + throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana."); + + return new Banana(count); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, banana, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + if (banana.CountOption.IsSet) + writer.WriteNumber("count", banana.CountOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs new file mode 100644 index 000000000000..1c74d878789d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -0,0 +1,225 @@ +// +/* + * fruity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Fruit + /// + public partial class Fruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Apple apple, Option color = default) + { + Apple = apple; + ColorOption = color; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Banana banana, Option color = default) + { + Banana = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get; set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get; set; } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Fruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..c6529e054024 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,33 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..67b671efd196 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/OneOf/src/Org.OpenAPITools/README.md @@ -0,0 +1,177 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + RootGetApiResponse apiResponse = await api.RootGetAsync("todo"); + Fruit model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + +Endpoints do not require authorization. + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: fruity +- appVersion: 0.0.1 +- appDescription: No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.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/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.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/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES new file mode 100644 index 000000000000..be38ed26d98c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES @@ -0,0 +1,234 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/AnotherFakeApi.md +docs/apis/DefaultApi.md +docs/apis/FakeApi.md +docs/apis/FakeClassnameTags123Api.md +docs/apis/PetApi.md +docs/apis/StoreApi.md +docs/apis/UserApi.md +docs/models/Activity.md +docs/models/ActivityOutputElementRepresentation.md +docs/models/AdditionalPropertiesClass.md +docs/models/Animal.md +docs/models/ApiResponse.md +docs/models/Apple.md +docs/models/AppleReq.md +docs/models/ArrayOfArrayOfNumberOnly.md +docs/models/ArrayOfNumberOnly.md +docs/models/ArrayTest.md +docs/models/Banana.md +docs/models/BananaReq.md +docs/models/BasquePig.md +docs/models/Capitalization.md +docs/models/Cat.md +docs/models/Category.md +docs/models/ChildCat.md +docs/models/ClassModel.md +docs/models/ComplexQuadrilateral.md +docs/models/DanishPig.md +docs/models/DateOnlyClass.md +docs/models/DeprecatedObject.md +docs/models/Dog.md +docs/models/Drawing.md +docs/models/EnumArrays.md +docs/models/EnumClass.md +docs/models/EnumTest.md +docs/models/EquilateralTriangle.md +docs/models/File.md +docs/models/FileSchemaTestClass.md +docs/models/Foo.md +docs/models/FooGetDefaultResponse.md +docs/models/FormatTest.md +docs/models/Fruit.md +docs/models/FruitReq.md +docs/models/GmFruit.md +docs/models/GrandparentAnimal.md +docs/models/HasOnlyReadOnly.md +docs/models/HealthCheckResult.md +docs/models/IsoscelesTriangle.md +docs/models/List.md +docs/models/LiteralStringClass.md +docs/models/Mammal.md +docs/models/MapTest.md +docs/models/MixLog.md +docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/Model200Response.md +docs/models/ModelClient.md +docs/models/Name.md +docs/models/NotificationtestGetElementsV1ResponseMPayload.md +docs/models/NullableClass.md +docs/models/NullableGuidClass.md +docs/models/NullableShape.md +docs/models/NumberOnly.md +docs/models/ObjectWithDeprecatedFields.md +docs/models/OneOfString.md +docs/models/Order.md +docs/models/OuterComposite.md +docs/models/OuterEnum.md +docs/models/OuterEnumDefaultValue.md +docs/models/OuterEnumInteger.md +docs/models/OuterEnumIntegerDefaultValue.md +docs/models/OuterEnumTest.md +docs/models/ParentPet.md +docs/models/Pet.md +docs/models/Pig.md +docs/models/PolymorphicProperty.md +docs/models/Quadrilateral.md +docs/models/QuadrilateralInterface.md +docs/models/ReadOnlyFirst.md +docs/models/RequiredClass.md +docs/models/Return.md +docs/models/RolesReportsHash.md +docs/models/RolesReportsHashRole.md +docs/models/ScaleneTriangle.md +docs/models/Shape.md +docs/models/ShapeInterface.md +docs/models/ShapeOrNull.md +docs/models/SimpleQuadrilateral.md +docs/models/SpecialModelName.md +docs/models/Tag.md +docs/models/TestCollectionEndingWithWordList.md +docs/models/TestCollectionEndingWithWordListObject.md +docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/Triangle.md +docs/models/TriangleInterface.md +docs/models/User.md +docs/models/Whale.md +docs/models/Zebra.md +docs/models/ZeroBasedEnum.md +docs/models/ZeroBasedEnumClass.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/AnotherFakeApi.cs +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/FakeApi.cs +src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Api/PetApi.cs +src/Org.OpenAPITools/Api/StoreApi.cs +src/Org.OpenAPITools/Api/UserApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiKeyToken.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/BasicToken.cs +src/Org.OpenAPITools/Client/BearerToken.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +src/Org.OpenAPITools/Client/HttpSigningToken.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/OAuthToken.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/Activity.cs +src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/Animal.cs +src/Org.OpenAPITools/Model/ApiResponse.cs +src/Org.OpenAPITools/Model/Apple.cs +src/Org.OpenAPITools/Model/AppleReq.cs +src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +src/Org.OpenAPITools/Model/ArrayTest.cs +src/Org.OpenAPITools/Model/Banana.cs +src/Org.OpenAPITools/Model/BananaReq.cs +src/Org.OpenAPITools/Model/BasquePig.cs +src/Org.OpenAPITools/Model/Capitalization.cs +src/Org.OpenAPITools/Model/Cat.cs +src/Org.OpenAPITools/Model/Category.cs +src/Org.OpenAPITools/Model/ChildCat.cs +src/Org.OpenAPITools/Model/ClassModel.cs +src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs +src/Org.OpenAPITools/Model/DeprecatedObject.cs +src/Org.OpenAPITools/Model/Dog.cs +src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EnumArrays.cs +src/Org.OpenAPITools/Model/EnumClass.cs +src/Org.OpenAPITools/Model/EnumTest.cs +src/Org.OpenAPITools/Model/EquilateralTriangle.cs +src/Org.OpenAPITools/Model/File.cs +src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +src/Org.OpenAPITools/Model/Foo.cs +src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +src/Org.OpenAPITools/Model/FormatTest.cs +src/Org.OpenAPITools/Model/Fruit.cs +src/Org.OpenAPITools/Model/FruitReq.cs +src/Org.OpenAPITools/Model/GmFruit.cs +src/Org.OpenAPITools/Model/GrandparentAnimal.cs +src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +src/Org.OpenAPITools/Model/HealthCheckResult.cs +src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +src/Org.OpenAPITools/Model/List.cs +src/Org.OpenAPITools/Model/LiteralStringClass.cs +src/Org.OpenAPITools/Model/Mammal.cs +src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/Model200Response.cs +src/Org.OpenAPITools/Model/ModelClient.cs +src/Org.OpenAPITools/Model/Name.cs +src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +src/Org.OpenAPITools/Model/NullableClass.cs +src/Org.OpenAPITools/Model/NullableGuidClass.cs +src/Org.OpenAPITools/Model/NullableShape.cs +src/Org.OpenAPITools/Model/NumberOnly.cs +src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +src/Org.OpenAPITools/Model/OneOfString.cs +src/Org.OpenAPITools/Model/Order.cs +src/Org.OpenAPITools/Model/OuterComposite.cs +src/Org.OpenAPITools/Model/OuterEnum.cs +src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs +src/Org.OpenAPITools/Model/OuterEnumInteger.cs +src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs +src/Org.OpenAPITools/Model/OuterEnumTest.cs +src/Org.OpenAPITools/Model/ParentPet.cs +src/Org.OpenAPITools/Model/Pet.cs +src/Org.OpenAPITools/Model/Pig.cs +src/Org.OpenAPITools/Model/PolymorphicProperty.cs +src/Org.OpenAPITools/Model/Quadrilateral.cs +src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Return.cs +src/Org.OpenAPITools/Model/RolesReportsHash.cs +src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +src/Org.OpenAPITools/Model/ScaleneTriangle.cs +src/Org.OpenAPITools/Model/Shape.cs +src/Org.OpenAPITools/Model/ShapeInterface.cs +src/Org.OpenAPITools/Model/ShapeOrNull.cs +src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +src/Org.OpenAPITools/Model/SpecialModelName.cs +src/Org.OpenAPITools/Model/Tag.cs +src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/Triangle.cs +src/Org.OpenAPITools/Model/TriangleInterface.cs +src/Org.OpenAPITools/Model/User.cs +src/Org.OpenAPITools/Model/Whale.cs +src/Org.OpenAPITools/Model/Zebra.cs +src/Org.OpenAPITools/Model/ZeroBasedEnum.cs +src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/Petstore/Org.OpenAPITools.sln new file mode 100644 index 000000000000..5b15451c9dcf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/README.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml new file mode 100644 index 000000000000..e4713d2621c4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -0,0 +1,3004 @@ +openapi: 3.0.0 +info: + description: "This spec is mainly for testing Petstore server and contains fake\ + \ endpoints, models. Please do not use this for any other purpose. Special characters:\ + \ \" \\" + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- description: petstore server + url: "http://{server}.swagger.io:{port}/v2" + variables: + server: + default: petstore + enum: + - petstore + - qa-petstore + - dev-petstore + port: + default: "80" + enum: + - "80" + - "8080" +- description: The local server + url: "https://localhost:8080/{version}" + variables: + version: + default: v2 + enum: + - v1 + - v2 +- description: The local server without variables + url: https://127.0.0.1/no_variable +tags: +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user +paths: + /roles/report: + get: + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/RolesReport' + type: array + description: returns report + /hello: + get: + description: Hello + operationId: Hello + responses: + "200": + content: + application/json: + schema: + items: + format: uuid + type: string + type: array + description: UUIDs + summary: Hello + /foo: + get: + responses: + default: + content: + application/json: + schema: + $ref: '#/components/schemas/_foo_get_default_response' + description: response + /pet: + post: + description: "" + operationId: addPet + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + "405": + description: Invalid input + security: + - http_signature_test: [] + - 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: + "400": + description: Invalid ID supplied + "404": + description: Pet not found + "405": + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + servers: + - url: http://petstore.swagger.io/v2 + - url: http://path-server-test.petstore.local/v2 + /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: + - http_signature_test: [] + - petstore_auth: + - write:pets + - 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: + - http_signature_test: [] + - petstore_auth: + - write:pets + - 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: [] + - api_key_query: [] + 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/{order_id}: + 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: order_id + 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: order_id + 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 + summary: Create user + tags: + - user + /user/createWithArray: + post: + description: "" + operationId: createUsersWithArrayInput + requestBody: + $ref: '#/components/requestBodies/UserArray' + responses: + default: + description: successful operation + 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 + 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: + 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 + 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 + 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 + "598": + description: Not a real HTTP status code + "599": + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Not a real HTTP status code with a return object + 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 + summary: Updated user + tags: + - user + /fake_classname_test: + patch: + description: To test class name in snake case + operationId: testClassname + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + security: + - api_key_query: [] + summary: To test class name in snake case + tags: + - fake_classname_tags 123#$%^ + /fake: + delete: + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + parameters: + - description: Required String in group parameters + explode: true + in: query + name: required_string_group + required: true + schema: + type: integer + style: form + - description: Required Boolean in group parameters + explode: false + in: header + name: required_boolean_group + required: true + schema: + type: boolean + style: simple + - description: Required Integer in group parameters + explode: true + in: query + name: required_int64_group + required: true + schema: + format: int64 + type: integer + style: form + - description: String in group parameters + explode: true + in: query + name: string_group + required: false + schema: + type: integer + style: form + - description: Boolean in group parameters + explode: false + in: header + name: boolean_group + required: false + schema: + type: boolean + style: simple + - description: Integer in group parameters + explode: true + in: query + name: int64_group + required: false + schema: + format: int64 + type: integer + style: form + responses: + "400": + description: Something wrong + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + tags: + - fake + x-group-parameters: true + get: + description: To test enum parameters + operationId: testEnumParameters + parameters: + - description: Header parameter enum test (string array) + explode: false + in: header + name: enum_header_string_array + required: false + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: simple + - description: Header parameter enum test (string) + explode: false + in: header + name: enum_header_string + required: false + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + style: simple + - description: Query parameter enum test (string array) + explode: true + in: query + name: enum_query_string_array + required: false + schema: + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + style: form + - description: Query parameter enum test (string) + explode: true + in: query + name: enum_query_string + required: false + schema: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + style: form + - description: Query parameter enum test (double) + explode: true + in: query + name: enum_query_integer + required: false + schema: + enum: + - 1 + - -2 + format: int32 + type: integer + style: form + - description: Query parameter enum test (double) + explode: true + in: query + name: enum_query_double + required: false + schema: + enum: + - 1.1 + - -1.2 + format: double + type: number + style: form + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testEnumParameters_request' + responses: + "400": + description: Invalid request + "404": + description: Not found + summary: To test enum parameters + tags: + - fake + patch: + description: To test "client" model + operationId: testClientModel + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test "client" model + tags: + - fake + post: + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testEndpointParameters_request' + responses: + "400": + description: Invalid username supplied + "404": + description: User not found + security: + - http_basic_test: [] + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + tags: + - fake + /fake/outer/number: + post: + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + description: Output number + tags: + - fake + /fake/outer/string: + post: + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + parameters: + - description: Required UUID String + explode: true + in: query + name: required_string_uuid + required: true + schema: + format: uuid + type: string + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + description: Output string + tags: + - fake + /fake/outer/boolean: + post: + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Output boolean + tags: + - fake + /fake/outer/composite: + post: + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + responses: + "200": + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + description: Output composite + tags: + - fake + /fake/jsonFormData: + get: + description: "" + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/testJsonFormData_request' + responses: + "200": + description: successful operation + summary: test json serialization of form data + tags: + - fake + /fake/additionalProperties-reference: + post: + description: "" + operationId: testAdditionalPropertiesReference + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FreeFormObject' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test referenced additionalProperties + tags: + - fake + /fake/stringMap-reference: + post: + description: "" + operationId: testStringMapReference + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MapOfString' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test referenced string map + tags: + - fake + /fake/inline-additionalProperties: + post: + description: "" + operationId: testInlineAdditionalProperties + requestBody: + content: + application/json: + schema: + additionalProperties: + type: string + type: object + description: request body + required: true + responses: + "200": + description: successful operation + summary: test inline additionalProperties + tags: + - fake + /fake/inline-freeform-additionalProperties: + post: + description: "" + operationId: testInlineFreeformAdditionalProperties + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/testInlineFreeformAdditionalProperties_request' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test inline free-form additionalProperties + tags: + - fake + /fake/body-with-query-params: + put: + operationId: testBodyWithQueryParams + parameters: + - explode: true + in: query + name: query + required: true + schema: + type: string + style: form + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + description: Success + tags: + - fake + /another-fake/dummy: + patch: + description: To test special tags and operation ID starting with number + operationId: 123_test_@#$%_special_tags + requestBody: + $ref: '#/components/requestBodies/Client' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: successful operation + summary: To test special tags + tags: + - $another-fake? + /fake/body-with-file-schema: + put: + description: "For this test, the body for this request much reference a schema\ + \ named `File`." + operationId: testBodyWithFileSchema + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + responses: + "200": + description: Success + tags: + - fake + /fake/test-query-parameters: + put: + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - explode: true + in: query + name: pipe + required: true + schema: + items: + type: string + type: array + style: form + - explode: false + in: query + name: ioutil + required: true + schema: + items: + type: string + type: array + style: form + - explode: false + in: query + name: http + required: true + schema: + items: + type: string + type: array + style: spaceDelimited + - explode: false + in: query + name: url + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: context + required: true + schema: + items: + type: string + type: array + style: form + - explode: true + in: query + name: requiredNotNullable + required: true + schema: + nullable: false + type: string + style: form + - explode: true + in: query + name: requiredNullable + required: true + schema: + nullable: true + type: string + style: form + - explode: true + in: query + name: notRequiredNotNullable + required: false + schema: + nullable: false + type: string + style: form + - explode: true + in: query + name: notRequiredNullable + required: false + schema: + nullable: true + type: string + style: form + responses: + "200": + description: Success + tags: + - fake + /fake/{petId}/uploadImageWithRequiredFile: + post: + description: "" + operationId: uploadFileWithRequiredFile + 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/uploadFileWithRequiredFile_request' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + security: + - petstore_auth: + - write:pets + - read:pets + summary: uploads an image (required) + tags: + - pet + /fake/health: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + description: The instance started successfully + summary: Health check endpoint + tags: + - fake + /fake/array-of-enums: + get: + operationId: getArrayOfEnums + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ArrayOfEnums' + description: Got named array of enums + summary: Array of Enums + tags: + - fake + /country: + post: + operationId: getCountry + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/getCountry_request' + responses: + "200": + description: OK + /test: + get: + operationId: Test + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/notificationtest-getElements-v1-Response-mPayload' + description: Successful response + summary: Retrieve an existing Notificationtest's Elements +components: + requestBodies: + UserArray: + content: + application/json: + examples: + simple-list: + description: Should not get into code examples + summary: Simple list example + value: + - username: foo + - username: bar + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + 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: + RolesReport: + description: Roles report + items: + $ref: '#/components/schemas/RolesReportsHash' + type: array + RolesReportsHash: + description: Role report Hash + example: + role: + name: name + role_uuid: 046b6c7f-0b8a-43b9-b35d-6489e6daee91 + properties: + role_uuid: + format: uuid + type: string + role: + $ref: '#/components/schemas/RolesReportsHash_role' + type: object + Foo: + example: + bar: bar + properties: + bar: + default: bar + type: string + type: object + Bar: + default: bar + type: string + Order: + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2020-02-02T20:20:20.000222Z + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + example: 2020-02-02T20:20:20.000222Z + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + type: object + xml: + name: Order + Category: + example: + name: default-name + id: 6 + properties: + id: + format: int64 + type: integer + name: + default: default-name + type: string + required: + - name + type: object + xml: + name: Category + User: + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + objectWithNoDeclaredPropsNullable: "{}" + phone: phone + objectWithNoDeclaredProps: "{}" + id: 0 + anyTypePropNullable: "" + email: email + anyTypeProp: "" + username: username + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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 + objectWithNoDeclaredProps: + description: test code generation for objects Value must be a map of strings + to values. It cannot be the 'null' value. + type: object + objectWithNoDeclaredPropsNullable: + description: test code generation for nullable objects. Value must be a + map of strings to values or the 'null' value. + nullable: true + type: object + anyTypeProp: + description: "test code generation for any type Here the 'type' attribute\ + \ is not specified, which means the value can be anything, including the\ + \ null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389" + anyTypePropNullable: + description: "test code generation for any type Here the 'type' attribute\ + \ is not specified, which means the value can be anything, including the\ + \ null value, string, number, boolean, array or object. The 'nullable'\ + \ attribute does not change the allowed values." + nullable: true + type: object + xml: + name: User + Tag: + example: + name: name + id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + type: object + xml: + name: Tag + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: default-name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + 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: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + type: object + xml: + name: Pet + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + lock: + type: string + abstract: + nullable: true + type: string + unsafe: + type: string + required: + - abstract + - lock + xml: + name: Return + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + "123Number": + readOnly: true + type: integer + required: + - name + xml: + name: Name + "200_response": + description: Model for testing model name starting with number + properties: + name: + format: int32 + type: integer + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - properties: + breed: + type: string + type: object + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - properties: + declawed: + type: boolean + type: object + Address: + additionalProperties: + type: integer + type: object + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - className + type: object + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + format_test: + properties: + integer: + maximum: 100 + minimum: 10 + multipleOf: 2 + type: integer + int32: + format: int32 + maximum: 200 + minimum: 20 + type: integer + unsigned_integer: + format: int32 + maximum: 200 + minimum: 20 + type: integer + x-unsigned: true + int64: + format: int64 + type: integer + unsigned_long: + format: int64 + type: integer + x-unsigned: true + number: + maximum: 543.2 + minimum: 32.1 + multipleOf: 32.5 + type: number + float: + format: float + maximum: 987.6 + minimum: 54.3 + type: number + double: + format: double + maximum: 123.4 + minimum: 67.8 + type: number + decimal: + format: number + type: string + string: + pattern: "/[a-z]/i" + type: string + byte: + format: byte + type: string + binary: + format: binary + type: string + date: + example: 2020-02-02 + format: date + type: string + dateTime: + example: 2007-12-03T10:15:30+01:00 + format: date-time + type: string + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + type: string + password: + format: password + maxLength: 64 + minLength: 10 + type: string + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + pattern: "^\\d{10}$" + type: string + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one + to three digits following i.e. Image_01. + pattern: "/^image_\\d{1,3}$/i" + type: string + pattern_with_backslash: + description: None + pattern: "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\\ + /([0-9]|[1-2][0-9]|3[0-2]))$" + type: string + required: + - byte + - date + - number + - password + type: object + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + Outer_Enum_Test: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + type: string + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_integer_only: + enum: + - 2 + - -2 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + required: + - enum_string_required + type: object + AdditionalPropertiesClass: + properties: + map_property: + additionalProperties: + type: string + type: object + map_of_map_property: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + anytype_1: {} + map_with_undeclared_properties_anytype_1: + type: object + map_with_undeclared_properties_anytype_2: + properties: {} + type: object + map_with_undeclared_properties_anytype_3: + additionalProperties: true + type: object + empty_map: + additionalProperties: false + description: "an object with no declared properties and no undeclared properties,\ + \ hence it's an empty map." + type: object + map_with_undeclared_properties_string: + additionalProperties: + type: string + type: object + type: object + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid_with_pattern: + format: uuid + pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" + type: string + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + List: + properties: + "123-list": + type: string + type: object + Client: + example: + client: client + properties: + client: + type: string + type: object + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + additionalProperties: + type: boolean + type: object + type: object + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object + x-cls-compliant: true + x-com-visible: true + ArrayOfNumberOnly: + properties: + ArrayNumber: + items: + type: number + type: array + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + FreeFormObject: + additionalProperties: true + description: A schema consisting only of additional properties + type: object + MapOfString: + additionalProperties: + type: string + description: A schema consisting only of additional properties of type string + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + nullable: true + type: string + OuterEnumInteger: + enum: + - 0 + - 1 + - 2 + type: integer + OuterEnumDefaultValue: + default: placed + enum: + - placed + - approved + - delivered + type: string + OuterEnumIntegerDefaultValue: + default: 0 + enum: + - 0 + - 1 + - 2 + type: integer + OuterComposite: + example: + my_string: my_string + my_number: 0.8008281904610115 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + type: object + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI + properties: + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + _special_model.name_: + properties: + $special[property.name]: + format: int64 + type: integer + _special_model.name_: + type: string + xml: + name: "$special[model.name]" + HealthCheckResult: + description: Just a string to inform instance is up and running. Make it nullable + in hope to get it as pointer in generated model. + example: + NullableMessage: NullableMessage + properties: + NullableMessage: + nullable: true + type: string + type: object + RequiredClass: + properties: + required_nullable_integer_prop: + nullable: true + type: integer + required_notnullableinteger_prop: + nullable: false + type: integer + not_required_nullable_integer_prop: + nullable: true + type: integer + not_required_notnullableinteger_prop: + nullable: false + type: integer + required_nullable_string_prop: + nullable: true + type: string + required_notnullable_string_prop: + nullable: false + type: string + notrequired_nullable_string_prop: + nullable: true + type: string + notrequired_notnullable_string_prop: + nullable: false + type: string + required_nullable_boolean_prop: + nullable: true + type: boolean + required_notnullable_boolean_prop: + nullable: false + type: boolean + notrequired_nullable_boolean_prop: + nullable: true + type: boolean + notrequired_notnullable_boolean_prop: + nullable: false + type: boolean + required_nullable_date_prop: + format: date + nullable: true + type: string + required_not_nullable_date_prop: + format: date + nullable: false + type: string + not_required_nullable_date_prop: + format: date + nullable: true + type: string + not_required_notnullable_date_prop: + format: date + nullable: false + type: string + required_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_nullable_datetime_prop: + format: date-time + nullable: true + type: string + notrequired_notnullable_datetime_prop: + format: date-time + nullable: false + type: string + required_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + required_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + notrequired_nullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: true + type: integer + notrequired_notnullable_enum_integer: + enum: + - 1 + - -1 + format: int32 + nullable: false + type: integer + required_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + required_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + notrequired_nullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: true + type: integer + notrequired_notnullable_enum_integer_only: + enum: + - 2 + - -2 + nullable: false + type: integer + required_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_nullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: true + type: string + notrequired_notnullable_enum_string: + enum: + - UPPER + - lower + - "" + - "Value\twith tab" + - Value with " quote + - Value with escaped \" quote + - |- + Duplicate + value + - "Duplicate\r\nvalue" + nullable: false + type: string + required_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + required_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + notrequired_nullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: true + notrequired_notnullable_outerEnumDefaultValue: + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + nullable: false + required_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + required_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + notrequired_nullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + notrequired_notnullable_uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: false + type: string + required_nullable_array_of_string: + items: + type: string + nullable: true + type: array + required_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + notrequired_nullable_array_of_string: + items: + type: string + nullable: true + type: array + notrequired_notnullable_array_of_string: + items: + type: string + nullable: false + type: array + required: + - required_not_nullable_date_prop + - required_notnullable_array_of_string + - required_notnullable_boolean_prop + - required_notnullable_datetime_prop + - required_notnullable_enum_integer + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_notnullable_outerEnumDefaultValue + - required_notnullable_string_prop + - required_notnullable_uuid + - required_notnullableinteger_prop + - required_nullable_array_of_string + - required_nullable_boolean_prop + - required_nullable_date_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_nullable_enum_integer_only + - required_nullable_enum_string + - required_nullable_integer_prop + - required_nullable_outerEnumDefaultValue + - required_nullable_string_prop + - required_nullable_uuid + type: object + NullableClass: + additionalProperties: + nullable: true + type: object + properties: + integer_prop: + nullable: true + type: integer + number_prop: + nullable: true + type: number + boolean_prop: + nullable: true + type: boolean + string_prop: + nullable: true + type: string + date_prop: + format: date + nullable: true + type: string + datetime_prop: + format: date-time + nullable: true + type: string + array_nullable_prop: + items: + type: object + nullable: true + type: array + array_and_items_nullable_prop: + items: + nullable: true + type: object + nullable: true + type: array + array_items_nullable: + items: + nullable: true + type: object + type: array + object_nullable_prop: + additionalProperties: + type: object + nullable: true + type: object + object_and_items_nullable_prop: + additionalProperties: + nullable: true + type: object + nullable: true + type: object + object_items_nullable: + additionalProperties: + nullable: true + type: object + type: object + type: object + fruit: + additionalProperties: false + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + apple: + nullable: true + properties: + cultivar: + pattern: "^[a-zA-Z\\s]*$" + type: string + origin: + pattern: "/^[A-Z\\s]*$/i" + type: string + color_code: + pattern: "^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$" + type: string + type: object + banana: + properties: + lengthCm: + type: number + type: object + mammal: + discriminator: + propertyName: className + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + - $ref: '#/components/schemas/Pig' + whale: + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + type: object + zebra: + additionalProperties: true + properties: + type: + enum: + - plains + - mountain + - grevys + type: string + className: + type: string + required: + - className + type: object + Pig: + discriminator: + propertyName: className + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + BasquePig: + properties: + className: + type: string + required: + - className + type: object + DanishPig: + properties: + className: + type: string + required: + - className + type: object + gmFruit: + additionalProperties: false + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + fruitReq: + additionalProperties: false + nullable: true + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + appleReq: + additionalProperties: false + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + type: object + bananaReq: + additionalProperties: false + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + type: object + Drawing: + additionalProperties: + $ref: '#/components/schemas/fruit' + properties: + mainShape: + $ref: '#/components/schemas/Shape' + shapeOrNull: + $ref: '#/components/schemas/ShapeOrNull' + nullableShape: + $ref: '#/components/schemas/NullableShape' + shapes: + items: + $ref: '#/components/schemas/Shape' + type: array + type: object + Shape: + discriminator: + propertyName: shapeType + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + ShapeOrNull: + description: The value may be a shape or the 'null' value. This is introduced + in OAS schema >= 3.1. + discriminator: + propertyName: shapeType + nullable: true + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + NullableShape: + description: The value may be a shape or the 'null' value. The 'nullable' attribute + was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema + >= 3.1. + discriminator: + propertyName: shapeType + nullable: true + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + discriminator: + propertyName: triangleType + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + additionalProperties: false + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + discriminator: + propertyName: quadrilateralType + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + GrandparentAnimal: + discriminator: + propertyName: pet_type + properties: + pet_type: + type: string + required: + - pet_type + type: object + ParentPet: + allOf: + - $ref: '#/components/schemas/GrandparentAnimal' + type: object + ChildCat: + allOf: + - $ref: '#/components/schemas/ParentPet' + - properties: + name: + type: string + pet_type: + default: ChildCat + enum: + - ChildCat + type: string + x-enum-as-string: true + required: + - pet_type + type: object + ArrayOfEnums: + items: + $ref: '#/components/schemas/OuterEnum' + type: array + DateTimeTest: + default: 2010-01-01T10:10:10.000111+01:00 + example: 2010-01-01T10:10:10.000111+01:00 + format: date-time + type: string + DeprecatedObject: + deprecated: true + properties: + name: + type: string + type: object + ObjectWithDeprecatedFields: + properties: + uuid: + type: string + id: + deprecated: true + type: number + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + deprecated: true + items: + $ref: '#/components/schemas/Bar' + type: array + type: object + PolymorphicProperty: + oneOf: + - type: boolean + - type: string + - type: object + - items: + $ref: '#/components/schemas/StringArrayItem' + type: array + StringArrayItem: + format: string + type: string + Activity: + description: test map of maps + properties: + activity_outputs: + additionalProperties: + $ref: '#/components/schemas/ActivityOutputRepresentation' + type: object + type: object + ActivityOutputRepresentation: + items: + $ref: '#/components/schemas/ActivityOutputElementRepresentation' + type: array + ActivityOutputElementRepresentation: + properties: + prop1: + type: string + prop2: + type: object + type: object + NullableGuidClass: + properties: + uuid: + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + format: uuid + nullable: true + type: string + type: object + DateOnlyClass: + properties: + dateOnlyProperty: + example: 2017-07-21 + format: date + type: string + type: object + TestCollectionEndingWithWordListObject: + properties: + TestCollectionEndingWithWordList: + items: + $ref: '#/components/schemas/TestCollectionEndingWithWordList' + type: array + type: object + TestCollectionEndingWithWordList: + properties: + value: + type: string + type: object + LiteralStringClass: + properties: + escapedLiteralString: + default: C:\\Users\\username + type: string + unescapedLiteralString: + default: C:\Users\username + type: string + type: object + OneOfString: + oneOf: + - pattern: ^a + type: string + - pattern: ^b + type: string + ZeroBasedEnum: + enum: + - unknown + - notUnknown + type: string + ZeroBasedEnumClass: + properties: + ZeroBasedEnum: + enum: + - unknown + - notUnknown + type: string + type: object + Custom-Variableobject-Response: + additionalProperties: true + description: A Variable object without predefined property names + type: object + Field-pkiNotificationtestID: + type: integer + notificationtest-getElements-v1-Response-mPayload: + example: + a_objVariableobject: + - null + - null + pkiNotificationtestID: 0 + properties: + pkiNotificationtestID: + type: integer + a_objVariableobject: + items: + $ref: '#/components/schemas/Custom-Variableobject-Response' + type: array + required: + - a_objVariableobject + - pkiNotificationtestID + type: object + MixLog: + properties: + id: + format: uuid + type: string + description: + type: string + mixDate: + format: date-time + type: string + shopId: + format: uuid + type: string + totalPrice: + format: float + nullable: true + type: number + totalRecalculations: + format: int32 + type: integer + totalOverPoors: + format: int32 + type: integer + totalSkips: + format: int32 + type: integer + totalUnderPours: + format: int32 + type: integer + formulaVersionDate: + format: date-time + type: string + someCode: + description: SomeCode is only required for color mixes + nullable: true + type: string + batchNumber: + type: string + brandCode: + description: BrandCode is only required for non-color mixes + type: string + brandId: + description: BrandId is only required for color mixes + type: string + brandName: + description: BrandName is only required for color mixes + type: string + categoryCode: + description: CategoryCode is not used anymore + type: string + color: + description: Color is only required for color mixes + type: string + colorDescription: + type: string + comment: + type: string + commercialProductCode: + type: string + productLineCode: + description: ProductLineCode is only required for color mixes + type: string + country: + type: string + createdBy: + type: string + createdByFirstName: + type: string + createdByLastName: + type: string + deltaECalculationRepaired: + type: string + deltaECalculationSprayout: + type: string + ownColorVariantNumber: + format: int32 + nullable: true + type: integer + primerProductId: + type: string + productId: + description: ProductId is only required for color mixes + type: string + productName: + description: ProductName is only required for color mixes + type: string + selectedVersionIndex: + format: int32 + type: integer + required: + - description + - formulaVersionDate + - id + - mixDate + - totalOverPoors + - totalRecalculations + - totalSkips + - totalUnderPours + type: object + uuid: + format: uuid + type: string + _foo_get_default_response: + example: + string: + bar: bar + properties: + string: + $ref: '#/components/schemas/Foo' + 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 + testEnumParameters_request: + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string + type: object + testEndpointParameters_request: + properties: + integer: + description: None + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: "/[a-z]/i" + type: string + pattern_without_delimiter: + description: None + pattern: "^[A-Z].*" + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + default: 2010-02-01T10:20:10.11111+01:00 + description: None + example: 2020-02-02T20:20:20.22222Z + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + type: object + testJsonFormData_request: + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + type: object + testInlineFreeformAdditionalProperties_request: + additionalProperties: true + properties: + someProperty: + type: string + type: object + uploadFileWithRequiredFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + type: object + getCountry_request: + allOf: + - properties: + country: + type: string + required: + - country + type: object + RolesReportsHash_role: + example: + name: name + properties: + name: + 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 + api_key_query: + in: query + name: api_key_query + type: apiKey + http_basic_test: + scheme: basic + type: http + bearer_test: + bearerFormat: JWT + scheme: bearer + type: http + http_signature_test: + scheme: signature + type: http + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/AnotherFakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/AnotherFakeApi.md new file mode 100644 index 000000000000..369488986579 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/AnotherFakeApi.md @@ -0,0 +1,99 @@ +# Org.OpenAPITools.Api.AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**Call123TestSpecialTags**](AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags | + + +# **Call123TestSpecialTags** +> ModelClient Call123TestSpecialTags (ModelClient modelClient) + +To test special tags + +To test special tags and operation ID starting with number + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class Call123TestSpecialTagsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new AnotherFakeApi(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test special tags + ModelClient result = apiInstance.Call123TestSpecialTags(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the Call123TestSpecialTagsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test special tags + ApiResponse response = apiInstance.Call123TestSpecialTagsWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTagsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..0bdfd6af3474 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/DefaultApi.md @@ -0,0 +1,429 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | +| [**Hello**](DefaultApi.md#hello) | **GET** /hello | Hello | +| [**RolesReportGet**](DefaultApi.md#rolesreportget) | **GET** /roles/report | | +| [**Test**](DefaultApi.md#test) | **GET** /test | Retrieve an existing Notificationtest's Elements | + + +# **FooGet** +> FooGetDefaultResponse FooGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FooGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + FooGetDefaultResponse result = apiInstance.FooGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.FooGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FooGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FooGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.FooGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**FooGetDefaultResponse**](FooGetDefaultResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | response | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **Hello** +> List<Guid> Hello () + +Hello + +Hello + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class HelloExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + // Hello + List result = apiInstance.Hello(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.Hello: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the HelloWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Hello + ApiResponse> response = apiInstance.HelloWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.HelloWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**List** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | UUIDs | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **RolesReportGet** +> List<List<RolesReportsHash>> RolesReportGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class RolesReportGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + List> result = apiInstance.RolesReportGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.RolesReportGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the RolesReportGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse>> response = apiInstance.RolesReportGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.RolesReportGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**List>** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | returns report | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **Test** +> NotificationtestGetElementsV1ResponseMPayload Test () + +Retrieve an existing Notificationtest's Elements + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + + try + { + // Retrieve an existing Notificationtest's Elements + NotificationtestGetElementsV1ResponseMPayload result = apiInstance.Test(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.Test: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Retrieve an existing Notificationtest's Elements + ApiResponse response = apiInstance.TestWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.TestWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**NotificationtestGetElementsV1ResponseMPayload**](NotificationtestGetElementsV1ResponseMPayload.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful response | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md new file mode 100644 index 000000000000..46abf3716ffe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md @@ -0,0 +1,1660 @@ +# Org.OpenAPITools.Api.FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**FakeHealthGet**](FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint | +| [**FakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | | +| [**FakeOuterCompositeSerialize**](FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | | +| [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | +| [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | +| [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | +| [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | +| [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | +| [**TestClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model | +| [**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 | +| [**TestEnumParameters**](FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters | +| [**TestGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | +| [**TestInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | +| [**TestInlineFreeformAdditionalProperties**](FakeApi.md#testinlinefreeformadditionalproperties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties | +| [**TestJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**TestQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | | +| [**TestStringMapReference**](FakeApi.md#teststringmapreference) | **POST** /fake/stringMap-reference | test referenced string map | + + +# **FakeHealthGet** +> HealthCheckResult FakeHealthGet () + +Health check endpoint + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeHealthGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Health check endpoint + HealthCheckResult result = apiInstance.FakeHealthGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeHealthGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeHealthGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Health check endpoint + ApiResponse response = apiInstance.FakeHealthGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeHealthGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**HealthCheckResult**](HealthCheckResult.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | The instance started successfully | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterBooleanSerialize** +> bool FakeOuterBooleanSerialize (bool body = null) + + + +Test serialization of outer boolean types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterBooleanSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var body = true; // bool | Input boolean as post body (optional) + + try + { + bool result = apiInstance.FakeOuterBooleanSerialize(body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterBooleanSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterBooleanSerializeWithHttpInfo(body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **body** | **bool** | Input boolean as post body | [optional] | + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output boolean | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterCompositeSerialize** +> OuterComposite FakeOuterCompositeSerialize (OuterComposite outerComposite = null) + + + +Test serialization of object with outer number type + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterCompositeSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var outerComposite = new OuterComposite(); // OuterComposite | Input composite as post body (optional) + + try + { + OuterComposite result = apiInstance.FakeOuterCompositeSerialize(outerComposite); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterCompositeSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterCompositeSerializeWithHttpInfo(outerComposite); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **outerComposite** | [**OuterComposite**](OuterComposite.md) | Input composite as post body | [optional] | + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output composite | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterNumberSerialize** +> decimal FakeOuterNumberSerialize (decimal body = null) + + + +Test serialization of outer number types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterNumberSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var body = 8.14D; // decimal | Input number as post body (optional) + + try + { + decimal result = apiInstance.FakeOuterNumberSerialize(body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterNumberSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterNumberSerializeWithHttpInfo(body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **body** | **decimal** | Input number as post body | [optional] | + +### Return type + +**decimal** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output number | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FakeOuterStringSerialize** +> string FakeOuterStringSerialize (Guid requiredStringUuid, string body = null) + + + +Test serialization of outer string types + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FakeOuterStringSerializeExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requiredStringUuid = "requiredStringUuid_example"; // Guid | Required UUID String + var body = "body_example"; // string | Input string as post body (optional) + + try + { + string result = apiInstance.FakeOuterStringSerialize(requiredStringUuid, body); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FakeOuterStringSerializeWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.FakeOuterStringSerializeWithHttpInfo(requiredStringUuid, body); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerializeWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredStringUuid** | **Guid** | Required UUID String | | +| **body** | **string** | Input string as post body | [optional] | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Output string | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetArrayOfEnums** +> List<OuterEnum> GetArrayOfEnums () + +Array of Enums + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetArrayOfEnumsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Array of Enums + List result = apiInstance.GetArrayOfEnums(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetArrayOfEnums: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetArrayOfEnumsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Array of Enums + ApiResponse> response = apiInstance.GetArrayOfEnumsWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetArrayOfEnumsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**List<OuterEnum>**](OuterEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got named array of enums | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestAdditionalPropertiesReference** +> void TestAdditionalPropertiesReference (Dictionary requestBody) + +test referenced additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestAdditionalPropertiesReferenceExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test referenced additionalProperties + apiInstance.TestAdditionalPropertiesReference(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestAdditionalPropertiesReference: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestAdditionalPropertiesReferenceWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test referenced additionalProperties + apiInstance.TestAdditionalPropertiesReferenceWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestAdditionalPropertiesReferenceWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, Object>**](Object.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestBodyWithFileSchema** +> void TestBodyWithFileSchema (FileSchemaTestClass fileSchemaTestClass) + + + +For this test, the body for this request much reference a schema named `File`. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestBodyWithFileSchemaExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var fileSchemaTestClass = new FileSchemaTestClass(); // FileSchemaTestClass | + + try + { + apiInstance.TestBodyWithFileSchema(fileSchemaTestClass); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchema: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestBodyWithFileSchemaWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchemaWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **fileSchemaTestClass** | [**FileSchemaTestClass**](FileSchemaTestClass.md) | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestBodyWithQueryParams** +> void TestBodyWithQueryParams (User user, string query) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestBodyWithQueryParamsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var user = new User(); // User | + var query = "query_example"; // string | + + try + { + apiInstance.TestBodyWithQueryParams(user, query); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParams: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestBodyWithQueryParamsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestBodyWithQueryParamsWithHttpInfo(user, query); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParamsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | | | +| **query** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestClientModel** +> ModelClient TestClientModel (ModelClient modelClient) + +To test \"client\" model + +To test \"client\" model + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestClientModelExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test \"client\" model + ModelClient result = apiInstance.TestClientModel(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestClientModelWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test \"client\" model + ApiResponse response = apiInstance.TestClientModelWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestClientModelWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestEndpointParameters** +> void TestEndpointParameters (byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, DateTime date = null, System.IO.Stream binary = null, float varFloat = null, int integer = null, int int32 = null, long int64 = null, string varString = null, string password = null, string callback = null, DateTime dateTime = null) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestEndpointParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure HTTP basic authorization: http_basic_test + config.Username = "YOUR_USERNAME"; + config.Password = "YOUR_PASSWORD"; + + var apiInstance = new FakeApi(config); + var varByte = System.Text.Encoding.ASCII.GetBytes("BYTE_ARRAY_DATA_HERE"); // byte[] | None + var number = 8.14D; // decimal | None + var varDouble = 1.2D; // double | None + var patternWithoutDelimiter = "patternWithoutDelimiter_example"; // string | None + var date = DateTime.Parse("2013-10-20"); // DateTime | None (optional) + var binary = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | None (optional) + var varFloat = 3.4F; // float | None (optional) + var integer = 56; // int | None (optional) + var int32 = 56; // int | None (optional) + var int64 = 789L; // long | None (optional) + var varString = "varString_example"; // string | None (optional) + var password = "password_example"; // string | None (optional) + var callback = "callback_example"; // string | None (optional) + var dateTime = DateTime.Parse(""2010-02-01T10:20:10.111110+01:00""); // DateTime | None (optional) (default to "2010-02-01T10:20:10.111110+01:00") + + try + { + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + apiInstance.TestEndpointParameters(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestEndpointParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + apiInstance.TestEndpointParametersWithHttpInfo(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestEndpointParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **varByte** | **byte[]** | None | | +| **number** | **decimal** | None | | +| **varDouble** | **double** | None | | +| **patternWithoutDelimiter** | **string** | None | | +| **date** | **DateTime** | None | [optional] | +| **binary** | **System.IO.Stream****System.IO.Stream** | None | [optional] | +| **varFloat** | **float** | None | [optional] | +| **integer** | **int** | None | [optional] | +| **int32** | **int** | None | [optional] | +| **int64** | **long** | None | [optional] | +| **varString** | **string** | None | [optional] | +| **password** | **string** | None | [optional] | +| **callback** | **string** | None | [optional] | +| **dateTime** | **DateTime** | None | [optional] [default to "2010-02-01T10:20:10.111110+01:00"] | + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestEnumParameters** +> void TestEnumParameters (List enumHeaderStringArray = null, List enumQueryStringArray = null, double enumQueryDouble = null, int enumQueryInteger = null, List enumFormStringArray = null, string enumHeaderString = null, string enumQueryString = null, string enumFormString = null) + +To test enum parameters + +To test enum parameters + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestEnumParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var enumHeaderStringArray = new List(); // List | Header parameter enum test (string array) (optional) + var enumQueryStringArray = new List(); // List | Query parameter enum test (string array) (optional) + var enumQueryDouble = 1.1D; // double | Query parameter enum test (double) (optional) + var enumQueryInteger = 1; // int | Query parameter enum test (double) (optional) + var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) (default to $) + var enumHeaderString = "_abc"; // string | Header parameter enum test (string) (optional) (default to -efg) + var enumQueryString = "_abc"; // string | Query parameter enum test (string) (optional) (default to -efg) + var enumFormString = "_abc"; // string | Form parameter enum test (string) (optional) (default to -efg) + + try + { + // To test enum parameters + apiInstance.TestEnumParameters(enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestEnumParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestEnumParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test enum parameters + apiInstance.TestEnumParametersWithHttpInfo(enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestEnumParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **enumHeaderStringArray** | [**List<string>**](string.md) | Header parameter enum test (string array) | [optional] | +| **enumQueryStringArray** | [**List<string>**](string.md) | Query parameter enum test (string array) | [optional] | +| **enumQueryDouble** | **double** | Query parameter enum test (double) | [optional] | +| **enumQueryInteger** | **int** | Query parameter enum test (double) | [optional] | +| **enumFormStringArray** | [**List<string>**](string.md) | Form parameter enum test (string array) | [optional] [default to $] | +| **enumHeaderString** | **string** | Header parameter enum test (string) | [optional] [default to -efg] | +| **enumQueryString** | **string** | Query parameter enum test (string) | [optional] [default to -efg] | +| **enumFormString** | **string** | Form parameter enum test (string) | [optional] [default to -efg] | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid request | - | +| **404** | Not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestGroupParameters** +> void TestGroupParameters (bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, bool booleanGroup = null, int stringGroup = null, long int64Group = null) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestGroupParametersExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure Bearer token for authorization: bearer_test + config.AccessToken = "YOUR_BEARER_TOKEN"; + + var apiInstance = new FakeApi(config); + var requiredBooleanGroup = true; // bool | Required Boolean in group parameters + var requiredStringGroup = 56; // int | Required String in group parameters + var requiredInt64Group = 789L; // long | Required Integer in group parameters + var booleanGroup = true; // bool | Boolean in group parameters (optional) + var stringGroup = 56; // int | String in group parameters (optional) + var int64Group = 789L; // long | Integer in group parameters (optional) + + try + { + // Fake endpoint to test group parameters (optional) + apiInstance.TestGroupParameters(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestGroupParameters: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestGroupParametersWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Fake endpoint to test group parameters (optional) + apiInstance.TestGroupParametersWithHttpInfo(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestGroupParametersWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredBooleanGroup** | **bool** | Required Boolean in group parameters | | +| **requiredStringGroup** | **int** | Required String in group parameters | | +| **requiredInt64Group** | **long** | Required Integer in group parameters | | +| **booleanGroup** | **bool** | Boolean in group parameters | [optional] | +| **stringGroup** | **int** | String in group parameters | [optional] | +| **int64Group** | **long** | Integer in group parameters | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[bearer_test](../README.md#bearer_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Something wrong | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestInlineAdditionalProperties** +> void TestInlineAdditionalProperties (Dictionary requestBody) + +test inline additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestInlineAdditionalPropertiesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test inline additionalProperties + apiInstance.TestInlineAdditionalProperties(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestInlineAdditionalProperties: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestInlineAdditionalPropertiesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test inline additionalProperties + apiInstance.TestInlineAdditionalPropertiesWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestInlineAdditionalPropertiesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, string>**](string.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestInlineFreeformAdditionalProperties** +> void TestInlineFreeformAdditionalProperties (TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + +test inline free-form additionalProperties + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestInlineFreeformAdditionalPropertiesExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var testInlineFreeformAdditionalPropertiesRequest = new TestInlineFreeformAdditionalPropertiesRequest(); // TestInlineFreeformAdditionalPropertiesRequest | request body + + try + { + // test inline free-form additionalProperties + apiInstance.TestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestInlineFreeformAdditionalProperties: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestInlineFreeformAdditionalPropertiesWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test inline free-form additionalProperties + apiInstance.TestInlineFreeformAdditionalPropertiesWithHttpInfo(testInlineFreeformAdditionalPropertiesRequest); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestInlineFreeformAdditionalPropertiesWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **testInlineFreeformAdditionalPropertiesRequest** | [**TestInlineFreeformAdditionalPropertiesRequest**](TestInlineFreeformAdditionalPropertiesRequest.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestJsonFormData** +> void TestJsonFormData (string param, string param2) + +test json serialization of form data + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestJsonFormDataExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var param = "param_example"; // string | field1 + var param2 = "param2_example"; // string | field2 + + try + { + // test json serialization of form data + apiInstance.TestJsonFormData(param, param2); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestJsonFormData: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestJsonFormDataWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test json serialization of form data + apiInstance.TestJsonFormDataWithHttpInfo(param, param2); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestJsonFormDataWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **param** | **string** | field1 | | +| **param2** | **string** | field2 | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestQueryParameterCollectionFormat** +> void TestQueryParameterCollectionFormat (List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, string notRequiredNotNullable = null, string notRequiredNullable = null) + + + +To test the collection format in query parameters + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestQueryParameterCollectionFormatExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var pipe = new List(); // List | + var ioutil = new List(); // List | + var http = new List(); // List | + var url = new List(); // List | + var context = new List(); // List | + var requiredNotNullable = "requiredNotNullable_example"; // string | + var requiredNullable = "requiredNullable_example"; // string | + var notRequiredNotNullable = "notRequiredNotNullable_example"; // string | (optional) + var notRequiredNullable = "notRequiredNullable_example"; // string | (optional) + + try + { + apiInstance.TestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestQueryParameterCollectionFormat: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestQueryParameterCollectionFormatWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.TestQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestQueryParameterCollectionFormatWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pipe** | [**List<string>**](string.md) | | | +| **ioutil** | [**List<string>**](string.md) | | | +| **http** | [**List<string>**](string.md) | | | +| **url** | [**List<string>**](string.md) | | | +| **context** | [**List<string>**](string.md) | | | +| **requiredNotNullable** | **string** | | | +| **requiredNullable** | **string** | | | +| **notRequiredNotNullable** | **string** | | [optional] | +| **notRequiredNullable** | **string** | | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Success | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **TestStringMapReference** +> void TestStringMapReference (Dictionary requestBody) + +test referenced string map + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestStringMapReferenceExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + var requestBody = new Dictionary(); // Dictionary | request body + + try + { + // test referenced string map + apiInstance.TestStringMapReference(requestBody); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.TestStringMapReference: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestStringMapReferenceWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // test referenced string map + apiInstance.TestStringMapReferenceWithHttpInfo(requestBody); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.TestStringMapReferenceWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requestBody** | [**Dictionary<string, string>**](string.md) | request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeClassnameTags123Api.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..dfe1adefd0a7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeClassnameTags123Api.md @@ -0,0 +1,104 @@ +# Org.OpenAPITools.Api.FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**TestClassname**](FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case | + + +# **TestClassname** +> ModelClient TestClassname (ModelClient modelClient) + +To test class name in snake case + +To test class name in snake case + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class TestClassnameExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key_query + config.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key_query", "Bearer"); + + var apiInstance = new FakeClassnameTags123Api(config); + var modelClient = new ModelClient(); // ModelClient | client model + + try + { + // To test class name in snake case + ModelClient result = apiInstance.TestClassname(modelClient); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassname: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the TestClassnameWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // To test class name in snake case + ApiResponse response = apiInstance.TestClassnameWithHttpInfo(modelClient); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassnameWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **modelClient** | [**ModelClient**](ModelClient.md) | client model | | + +### Return type + +[**ModelClient**](ModelClient.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md new file mode 100644 index 000000000000..407fb30dccb4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/PetApi.md @@ -0,0 +1,860 @@ +# Org.OpenAPITools.Api.PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**AddPet**](PetApi.md#addpet) | **POST** /pet | Add a new pet to the store | +| [**DeletePet**](PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet | +| [**FindPetsByStatus**](PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status | +| [**FindPetsByTags**](PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags | +| [**GetPetById**](PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID | +| [**UpdatePet**](PetApi.md#updatepet) | **PUT** /pet | Update an existing pet | +| [**UpdatePetWithForm**](PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data | +| [**UploadFile**](PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image | +| [**UploadFileWithRequiredFile**](PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) | + + +# **AddPet** +> void AddPet (Pet pet) + +Add a new pet to the store + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class AddPetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var pet = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Add a new pet to the store + apiInstance.AddPet(pet); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.AddPet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the AddPetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Add a new pet to the store + apiInstance.AddPetWithHttpInfo(pet); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.AddPetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **DeletePet** +> void DeletePet (long petId, string apiKey = null) + +Deletes a pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeletePetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | Pet id to delete + var apiKey = "apiKey_example"; // string | (optional) + + try + { + // Deletes a pet + apiInstance.DeletePet(petId, apiKey); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeletePetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Deletes a pet + apiInstance.DeletePetWithHttpInfo(petId, apiKey); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.DeletePetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | Pet id to delete | | +| **apiKey** | **string** | | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid pet value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FindPetsByStatus** +> List<Pet> FindPetsByStatus (List status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FindPetsByStatusExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var status = new List(); // List | Status values that need to be considered for filter + + try + { + // Finds Pets by status + List result = apiInstance.FindPetsByStatus(status); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FindPetsByStatusWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Finds Pets by status + ApiResponse> response = apiInstance.FindPetsByStatusWithHttpInfo(status); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.FindPetsByStatusWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **status** | [**List<string>**](string.md) | Status values that need to be considered for filter | | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid status value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **FindPetsByTags** +> List<Pet> FindPetsByTags (List tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class FindPetsByTagsExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var tags = new List(); // List | Tags to filter by + + try + { + // Finds Pets by tags + List result = apiInstance.FindPetsByTags(tags); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the FindPetsByTagsWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Finds Pets by tags + ApiResponse> response = apiInstance.FindPetsByTagsWithHttpInfo(tags); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.FindPetsByTagsWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **tags** | [**List<string>**](string.md) | Tags to filter by | | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid tag value | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetPetById** +> Pet GetPetById (long petId) + +Find pet by ID + +Returns a single pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetPetByIdExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key + config.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key", "Bearer"); + // Configure API key authorization: api_key_query + config.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key_query", "Bearer"); + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to return + + try + { + // Find pet by ID + Pet result = apiInstance.GetPetById(petId); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetPetByIdWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Find pet by ID + ApiResponse response = apiInstance.GetPetByIdWithHttpInfo(petId); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.GetPetByIdWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to return | | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key), [api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdatePet** +> void UpdatePet (Pet pet) + +Update an existing pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdatePetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var pet = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Update an existing pet + apiInstance.UpdatePet(pet); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdatePetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Update an existing pet + apiInstance.UpdatePetWithHttpInfo(pet); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UpdatePetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Pet not found | - | +| **405** | Validation exception | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdatePetWithForm** +> void UpdatePetWithForm (long petId, string name = null, string status = null) + +Updates a pet in the store with form data + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdatePetWithFormExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet that needs to be updated + var name = "name_example"; // string | Updated name of the pet (optional) + var status = "status_example"; // string | Updated status of the pet (optional) + + try + { + // Updates a pet in the store with form data + apiInstance.UpdatePetWithForm(petId, name, status); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdatePetWithFormWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Updates a pet in the store with form data + apiInstance.UpdatePetWithFormWithHttpInfo(petId, name, status); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UpdatePetWithFormWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet that needs to be updated | | +| **name** | **string** | Updated name of the pet | [optional] | +| **status** | **string** | Updated status of the pet | [optional] | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **405** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UploadFile** +> ApiResponse UploadFile (long petId, System.IO.Stream file = null, string additionalMetadata = null) + +uploads an image + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFileExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var petId = 789L; // long | ID of pet to update + var file = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | file to upload (optional) + var additionalMetadata = "additionalMetadata_example"; // string | Additional data to pass to server (optional) + + try + { + // uploads an image + ApiResponse result = apiInstance.UploadFile(petId, file, additionalMetadata); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFileWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an image + ApiResponse response = apiInstance.UploadFileWithHttpInfo(petId, file, additionalMetadata); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFileWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **petId** | **long** | ID of pet to update | | +| **file** | **System.IO.Stream****System.IO.Stream** | file to upload | [optional] | +| **additionalMetadata** | **string** | Additional data to pass to server | [optional] | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UploadFileWithRequiredFile** +> ApiResponse UploadFileWithRequiredFile (System.IO.Stream requiredFile, long petId, string additionalMetadata = null) + +uploads an image (required) + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UploadFileWithRequiredFileExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure OAuth2 access token for authorization: petstore_auth + config.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(config); + var requiredFile = new System.IO.MemoryStream(System.IO.File.ReadAllBytes("/path/to/file.txt")); // System.IO.Stream | file to upload + var petId = 789L; // long | ID of pet to update + var additionalMetadata = "additionalMetadata_example"; // string | Additional data to pass to server (optional) + + try + { + // uploads an image (required) + ApiResponse result = apiInstance.UploadFileWithRequiredFile(requiredFile, petId, additionalMetadata); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFile: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UploadFileWithRequiredFileWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // uploads an image (required) + ApiResponse response = apiInstance.UploadFileWithRequiredFileWithHttpInfo(requiredFile, petId, additionalMetadata); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFileWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **requiredFile** | **System.IO.Stream****System.IO.Stream** | file to upload | | +| **petId** | **long** | ID of pet to update | | +| **additionalMetadata** | **string** | Additional data to pass to server | [optional] | + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/StoreApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/StoreApi.md new file mode 100644 index 000000000000..4a1cd29ada7a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/StoreApi.md @@ -0,0 +1,373 @@ +# Org.OpenAPITools.Api.StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**DeleteOrder**](StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID | +| [**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status | +| [**GetOrderById**](StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID | +| [**PlaceOrder**](StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet | + + +# **DeleteOrder** +> void DeleteOrder (string orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeleteOrderExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var orderId = "orderId_example"; // string | ID of the order that needs to be deleted + + try + { + // Delete purchase order by ID + apiInstance.DeleteOrder(orderId); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeleteOrderWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Delete purchase order by ID + apiInstance.DeleteOrderWithHttpInfo(orderId); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.DeleteOrderWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **orderId** | **string** | ID of the order that needs to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetInventory** +> Dictionary<string, int> GetInventory () + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetInventoryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // Configure API key authorization: api_key + config.AddApiKey("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // config.AddApiKeyPrefix("api_key", "Bearer"); + + var apiInstance = new StoreApi(config); + + try + { + // Returns pet inventories by status + Dictionary result = apiInstance.GetInventory(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetInventoryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Returns pet inventories by status + ApiResponse> response = apiInstance.GetInventoryWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.GetInventoryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +**Dictionary** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetOrderById** +> Order GetOrderById (long orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetOrderByIdExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var orderId = 789L; // long | ID of pet that needs to be fetched + + try + { + // Find purchase order by ID + Order result = apiInstance.GetOrderById(orderId); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetOrderByIdWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Find purchase order by ID + ApiResponse response = apiInstance.GetOrderByIdWithHttpInfo(orderId); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.GetOrderByIdWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **orderId** | **long** | ID of pet that needs to be fetched | | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid ID supplied | - | +| **404** | Order not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **PlaceOrder** +> Order PlaceOrder (Order order) + +Place an order for a pet + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class PlaceOrderExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new StoreApi(config); + var order = new Order(); // Order | order placed for purchasing the pet + + try + { + // Place an order for a pet + Order result = apiInstance.PlaceOrder(order); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the PlaceOrderWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Place an order for a pet + ApiResponse response = apiInstance.PlaceOrderWithHttpInfo(order); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling StoreApi.PlaceOrderWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **order** | [**Order**](Order.md) | order placed for purchasing the pet | | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid Order | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/UserApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/UserApi.md new file mode 100644 index 000000000000..ee189c866ec5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/UserApi.md @@ -0,0 +1,715 @@ +# Org.OpenAPITools.Api.UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user | +| [**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array | +| [**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array | +| [**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user | +| [**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name | +| [**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system | +| [**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session | +| [**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user | + + +# **CreateUser** +> void CreateUser (User user) + +Create user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new User(); // User | Created user object + + try + { + // Create user + apiInstance.CreateUser(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Create user + apiInstance.CreateUserWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | Created user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **CreateUsersWithArrayInput** +> void CreateUsersWithArrayInput (List user) + +Creates list of users with given input array + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUsersWithArrayInputExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInput(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUsersWithArrayInputWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInputWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInputWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**List<User>**](User.md) | List of user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **CreateUsersWithListInput** +> void CreateUsersWithListInput (List user) + +Creates list of users with given input array + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class CreateUsersWithListInputExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithListInput(user); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the CreateUsersWithListInputWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Creates list of users with given input array + apiInstance.CreateUsersWithListInputWithHttpInfo(user); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.CreateUsersWithListInputWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**List<User>**](User.md) | List of user object | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **DeleteUser** +> void DeleteUser (string username) + +Delete user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class DeleteUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The name that needs to be deleted + + try + { + // Delete user + apiInstance.DeleteUser(username); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the DeleteUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Delete user + apiInstance.DeleteUserWithHttpInfo(username); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.DeleteUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The name that needs to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid username supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetUserByName** +> User GetUserByName (string username) + +Get user by user name + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetUserByNameExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. + + try + { + // Get user by user name + User result = apiInstance.GetUserByName(username); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetUserByNameWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Get user by user name + ApiResponse response = apiInstance.GetUserByNameWithHttpInfo(username); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.GetUserByNameWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The name that needs to be fetched. Use user1 for testing. | | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | +| **400** | Invalid username supplied | - | +| **404** | User not found | - | +| **598** | Not a real HTTP status code | - | +| **599** | Not a real HTTP status code with a return object | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **LoginUser** +> string LoginUser (string username, string password) + +Logs user into the system + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class LoginUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var username = "username_example"; // string | The user name for login + var password = "password_example"; // string | The password for login in clear text + + try + { + // Logs user into the system + string result = apiInstance.LoginUser(username, password); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the LoginUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Logs user into the system + ApiResponse response = apiInstance.LoginUserWithHttpInfo(username, password); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.LoginUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **username** | **string** | The user name for login | | +| **password** | **string** | The password for login in clear text | | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication.
* X-Rate-Limit - calls per hour allowed by the user
* X-Expires-After - date in UTC when token expires
| +| **400** | Invalid username/password supplied | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **LogoutUser** +> void LogoutUser () + +Logs out current logged in user session + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class LogoutUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + + try + { + // Logs out current logged in user session + apiInstance.LogoutUser(); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the LogoutUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Logs out current logged in user session + apiInstance.LogoutUserWithHttpInfo(); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.LogoutUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **0** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **UpdateUser** +> void UpdateUser (User user, string username) + +Updated user + +This can only be done by the logged in user. + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class UpdateUserExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new UserApi(config); + var user = new User(); // User | Updated user object + var username = "username_example"; // string | name that need to be deleted + + try + { + // Updated user + apiInstance.UpdateUser(user, username); + } + catch (ApiException e) + { + Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the UpdateUserWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Updated user + apiInstance.UpdateUserWithHttpInfo(user, username); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling UserApi.UpdateUserWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **user** | [**User**](User.md) | Updated user object | | +| **username** | **string** | name that need to be deleted | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **400** | Invalid user supplied | - | +| **404** | User not found | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Activity.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Activity.md new file mode 100644 index 000000000000..6f69ec32545d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Activity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Activity +test map of maps + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ActivityOutputs** | **Dictionary<string, List<ActivityOutputElementRepresentation>>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ActivityOutputElementRepresentation.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ActivityOutputElementRepresentation.md new file mode 100644 index 000000000000..33d79a27692f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ActivityOutputElementRepresentation.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ActivityOutputElementRepresentation + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Prop1** | **string** | | [optional] +**Prop2** | **Object** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AdditionalPropertiesClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AdditionalPropertiesClass.md new file mode 100644 index 000000000000..2bbe882fcfcc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AdditionalPropertiesClass.md @@ -0,0 +1,17 @@ +# Org.OpenAPITools.Model.AdditionalPropertiesClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Anytype1** | **Object** | | [optional] +**EmptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional] +**MapOfMapProperty** | **Dictionary<string, Dictionary<string, string>>** | | [optional] +**MapProperty** | **Dictionary<string, string>** | | [optional] +**MapWithUndeclaredPropertiesAnytype1** | **Object** | | [optional] +**MapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional] +**MapWithUndeclaredPropertiesAnytype3** | **Dictionary<string, Object>** | | [optional] +**MapWithUndeclaredPropertiesString** | **Dictionary<string, string>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Animal.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Animal.md new file mode 100644 index 000000000000..1a1760bd8697 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Animal.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Animal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ApiResponse.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ApiResponse.md new file mode 100644 index 000000000000..d89ed1a25dc7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ApiResponse.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.ApiResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int** | | [optional] +**Message** | **string** | | [optional] +**Type** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Apple.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Apple.md new file mode 100644 index 000000000000..9ad1da8cd688 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Apple.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ColorCode** | **string** | | [optional] +**Cultivar** | **string** | | [optional] +**Origin** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AppleReq.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AppleReq.md new file mode 100644 index 000000000000..325521123f12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/AppleReq.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.AppleReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Cultivar** | **string** | | +**Mealy** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 000000000000..a23ba59e609c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ArrayOfArrayOfNumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayArrayNumber** | **List<List<decimal>>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfNumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfNumberOnly.md new file mode 100644 index 000000000000..10b8413439b8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ArrayOfNumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayNumber** | **List<decimal>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayTest.md new file mode 100644 index 000000000000..ed572120cd6d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ArrayTest.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.ArrayTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayArrayOfInteger** | **List<List<long>>** | | [optional] +**ArrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [optional] +**ArrayOfString** | **List<string>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Banana.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Banana.md new file mode 100644 index 000000000000..d32e90cf2985 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Banana.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BananaReq.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BananaReq.md new file mode 100644 index 000000000000..c8372b73c5f7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BananaReq.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.BananaReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | **decimal** | | +**Sweet** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BasquePig.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BasquePig.md new file mode 100644 index 000000000000..db4f7a362268 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/BasquePig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.BasquePig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Capitalization.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Capitalization.md new file mode 100644 index 000000000000..9e225c17232a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Capitalization.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Capitalization + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ATT_NAME** | **string** | Name of the pet | [optional] +**CapitalCamel** | **string** | | [optional] +**CapitalSnake** | **string** | | [optional] +**SCAETHFlowPoints** | **string** | | [optional] +**SmallCamel** | **string** | | [optional] +**SmallSnake** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Cat.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Cat.md new file mode 100644 index 000000000000..310a5e6575ec --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Cat.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Cat + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Declawed** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Category.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Category.md new file mode 100644 index 000000000000..6eb0a2e13eaa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Category.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Category + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long** | | [optional] +**Name** | **string** | | [default to "default-name"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ChildCat.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ChildCat.md new file mode 100644 index 000000000000..88fe8f7a7fdd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ChildCat.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ChildCat + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] +**PetType** | **string** | | [default to PetTypeEnum.ChildCat] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ClassModel.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ClassModel.md new file mode 100644 index 000000000000..bb35816c9148 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ClassModel.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ClassModel +Model for testing model with \"_class\" property + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Class** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ComplexQuadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ComplexQuadrilateral.md new file mode 100644 index 000000000000..fb00d4ebf089 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ComplexQuadrilateral.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ComplexQuadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DanishPig.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DanishPig.md new file mode 100644 index 000000000000..4d6ec1400a7e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DanishPig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DanishPig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DateOnlyClass.md new file mode 100644 index 000000000000..5dd63b313ccf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DeprecatedObject.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DeprecatedObject.md new file mode 100644 index 000000000000..e90c59555a0d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/DeprecatedObject.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DeprecatedObject + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Dog.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Dog.md new file mode 100644 index 000000000000..70cdc80e83e0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Dog.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Dog + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Color** | **string** | | [optional] [default to "red"] +**Breed** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Drawing.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Drawing.md new file mode 100644 index 000000000000..95f49b2ed600 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Drawing.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.Drawing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MainShape** | [**Shape**](Shape.md) | | [optional] +**NullableShape** | [**NullableShape**](NullableShape.md) | | [optional] +**ShapeOrNull** | [**ShapeOrNull**](ShapeOrNull.md) | | [optional] +**Shapes** | [**List<Shape>**](Shape.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumArrays.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumArrays.md new file mode 100644 index 000000000000..7467f67978c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumArrays.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.EnumArrays + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayEnum** | **List<EnumArrays.ArrayEnumEnum>** | | [optional] +**JustSymbol** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumClass.md new file mode 100644 index 000000000000..d259f0f46968 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumClass.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.EnumClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumTest.md new file mode 100644 index 000000000000..ebd7ccf2c864 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EnumTest.md @@ -0,0 +1,18 @@ +# Org.OpenAPITools.Model.EnumTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EnumStringRequired** | **string** | | +**EnumInteger** | **int** | | [optional] +**EnumIntegerOnly** | **int** | | [optional] +**EnumNumber** | **double** | | [optional] +**EnumString** | **string** | | [optional] +**OuterEnum** | **OuterEnum** | | [optional] +**OuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**OuterEnumInteger** | **OuterEnumInteger** | | [optional] +**OuterEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EquilateralTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EquilateralTriangle.md new file mode 100644 index 000000000000..8360b5c16a5b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EquilateralTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.EquilateralTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/File.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/File.md new file mode 100644 index 000000000000..58b9c2fc3698 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/File.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.File +Must be named `File` for test. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SourceURI** | **string** | Test capitalization | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FileSchemaTestClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FileSchemaTestClass.md new file mode 100644 index 000000000000..a47efad77d8a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FileSchemaTestClass.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.FileSchemaTestClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**File** | [**File**](File.md) | | [optional] +**Files** | [**List<File>**](File.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Foo.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Foo.md new file mode 100644 index 000000000000..b9e7d261736f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Foo.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Foo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [default to "bar"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FooGetDefaultResponse.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FooGetDefaultResponse.md new file mode 100644 index 000000000000..47e50daca3e1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FooGetDefaultResponse.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.FooGetDefaultResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**String** | [**Foo**](Foo.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md new file mode 100644 index 000000000000..0983002c5da1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FormatTest.md @@ -0,0 +1,28 @@ +# Org.OpenAPITools.Model.FormatTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Byte** | **byte[]** | | +**Date** | **DateTime** | | +**Number** | **decimal** | | +**Password** | **string** | | +**Binary** | **System.IO.Stream** | | [optional] +**DateTime** | **DateTime** | | [optional] +**Decimal** | **decimal** | | [optional] +**Double** | **double** | | [optional] +**Float** | **float** | | [optional] +**Int32** | **int** | | [optional] +**Int64** | **long** | | [optional] +**Integer** | **int** | | [optional] +**PatternWithBackslash** | **string** | None | [optional] +**PatternWithDigits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional] +**PatternWithDigitsAndDelimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] +**String** | **string** | | [optional] +**UnsignedInteger** | **uint** | | [optional] +**UnsignedLong** | **ulong** | | [optional] +**Uuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Fruit.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Fruit.md new file mode 100644 index 000000000000..b3bee18f7ba0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Fruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FruitReq.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FruitReq.md new file mode 100644 index 000000000000..38ab0c1a6caa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/FruitReq.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.FruitReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GmFruit.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GmFruit.md new file mode 100644 index 000000000000..584c4fd323d8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GmFruit.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.GmFruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GrandparentAnimal.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GrandparentAnimal.md new file mode 100644 index 000000000000..eca96162b6f8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/GrandparentAnimal.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.GrandparentAnimal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**PetType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HasOnlyReadOnly.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HasOnlyReadOnly.md new file mode 100644 index 000000000000..060a614a6981 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.HasOnlyReadOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [readonly] +**Foo** | **string** | | [optional] [readonly] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HealthCheckResult.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HealthCheckResult.md new file mode 100644 index 000000000000..682cfc50e3a4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/HealthCheckResult.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.HealthCheckResult +Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**NullableMessage** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/IsoscelesTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/IsoscelesTriangle.md new file mode 100644 index 000000000000..07c62ac93382 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/IsoscelesTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.IsoscelesTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/List.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/List.md new file mode 100644 index 000000000000..0b54858ac247 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/List.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.List + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Var123List** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/LiteralStringClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/LiteralStringClass.md new file mode 100644 index 000000000000..782021909655 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/LiteralStringClass.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.LiteralStringClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**EscapedLiteralString** | **string** | | [optional] [default to "C:\\Users\\username"] +**UnescapedLiteralString** | **string** | | [optional] [default to "C:\Users\username"] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Mammal.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Mammal.md new file mode 100644 index 000000000000..ac14f00c0ff0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Mammal.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Mammal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MapTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MapTest.md new file mode 100644 index 000000000000..5dd27228bb06 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MapTest.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.MapTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DirectMap** | **Dictionary<string, bool>** | | [optional] +**IndirectMap** | **Dictionary<string, bool>** | | [optional] +**MapMapOfString** | **Dictionary<string, Dictionary<string, string>>** | | [optional] +**MapOfEnumString** | **Dictionary<string, MapTest.InnerEnum>** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixLog.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixLog.md new file mode 100644 index 000000000000..5184c03bea97 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixLog.md @@ -0,0 +1,41 @@ +# Org.OpenAPITools.Model.MixLog + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Description** | **string** | | +**FormulaVersionDate** | **DateTime** | | +**Id** | **Guid** | | +**MixDate** | **DateTime** | | +**TotalOverPoors** | **int** | | +**TotalRecalculations** | **int** | | +**TotalSkips** | **int** | | +**TotalUnderPours** | **int** | | +**BatchNumber** | **string** | | [optional] +**BrandCode** | **string** | BrandCode is only required for non-color mixes | [optional] +**BrandId** | **string** | BrandId is only required for color mixes | [optional] +**BrandName** | **string** | BrandName is only required for color mixes | [optional] +**CategoryCode** | **string** | CategoryCode is not used anymore | [optional] +**Color** | **string** | Color is only required for color mixes | [optional] +**ColorDescription** | **string** | | [optional] +**Comment** | **string** | | [optional] +**CommercialProductCode** | **string** | | [optional] +**Country** | **string** | | [optional] +**CreatedBy** | **string** | | [optional] +**CreatedByFirstName** | **string** | | [optional] +**CreatedByLastName** | **string** | | [optional] +**DeltaECalculationRepaired** | **string** | | [optional] +**DeltaECalculationSprayout** | **string** | | [optional] +**OwnColorVariantNumber** | **int** | | [optional] +**PrimerProductId** | **string** | | [optional] +**ProductId** | **string** | ProductId is only required for color mixes | [optional] +**ProductLineCode** | **string** | ProductLineCode is only required for color mixes | [optional] +**ProductName** | **string** | ProductName is only required for color mixes | [optional] +**SelectedVersionIndex** | **int** | | [optional] +**ShopId** | **Guid** | | [optional] +**SomeCode** | **string** | SomeCode is only required for color mixes | [optional] +**TotalPrice** | **float** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 000000000000..1bc0740add9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.MixedPropertiesAndAdditionalPropertiesClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateTime** | **DateTime** | | [optional] +**Map** | [**Dictionary<string, Animal>**](Animal.md) | | [optional] +**Uuid** | **Guid** | | [optional] +**UuidWithPattern** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Model200Response.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Model200Response.md new file mode 100644 index 000000000000..2752a0d87c82 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Model200Response.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Model200Response +Model for testing model name starting with number + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Class** | **string** | | [optional] +**Name** | **int** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ModelClient.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ModelClient.md new file mode 100644 index 000000000000..c658e84ef57e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ModelClient.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ModelClient + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarClient** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Name.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Name.md new file mode 100644 index 000000000000..ffe61a31d61b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Name.md @@ -0,0 +1,14 @@ +# Org.OpenAPITools.Model.Name +Model for testing model name same as property name + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarName** | **int** | | +**Property** | **string** | | [optional] +**SnakeCase** | **int** | | [optional] [readonly] +**Var123Number** | **int** | | [optional] [readonly] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NotificationtestGetElementsV1ResponseMPayload.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NotificationtestGetElementsV1ResponseMPayload.md new file mode 100644 index 000000000000..25f223a8360a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NotificationtestGetElementsV1ResponseMPayload.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AObjVariableobject** | **List<Dictionary<string, Object>>** | | +**PkiNotificationtestID** | **int** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableClass.md new file mode 100644 index 000000000000..5d9965f55c0a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableClass.md @@ -0,0 +1,21 @@ +# Org.OpenAPITools.Model.NullableClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayAndItemsNullableProp** | **List<Object>** | | [optional] +**ArrayItemsNullable** | **List<Object>** | | [optional] +**ArrayNullableProp** | **List<Object>** | | [optional] +**BooleanProp** | **bool** | | [optional] +**DateProp** | **DateTime** | | [optional] +**DatetimeProp** | **DateTime** | | [optional] +**IntegerProp** | **int** | | [optional] +**NumberProp** | **decimal** | | [optional] +**ObjectAndItemsNullableProp** | **Dictionary<string, Object>** | | [optional] +**ObjectItemsNullable** | **Dictionary<string, Object>** | | [optional] +**ObjectNullableProp** | **Dictionary<string, Object>** | | [optional] +**StringProp** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableGuidClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableGuidClass.md new file mode 100644 index 000000000000..8d939afe9984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableGuidClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.NullableGuidClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Uuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableShape.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableShape.md new file mode 100644 index 000000000000..2720167ccaaa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NullableShape.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.NullableShape +The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NumberOnly.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NumberOnly.md new file mode 100644 index 000000000000..1b83cce764d3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/NumberOnly.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.NumberOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**JustNumber** | **decimal** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ObjectWithDeprecatedFields.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ObjectWithDeprecatedFields.md new file mode 100644 index 000000000000..9f44c24d19ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ObjectWithDeprecatedFields.md @@ -0,0 +1,13 @@ +# Org.OpenAPITools.Model.ObjectWithDeprecatedFields + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bars** | **List<string>** | | [optional] +**DeprecatedRef** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] +**Id** | **decimal** | | [optional] +**Uuid** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OneOfString.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OneOfString.md new file mode 100644 index 000000000000..54caf618776c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OneOfString.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OneOfString + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Order.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Order.md new file mode 100644 index 000000000000..f7d6827ed5c9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Order.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Complete** | **bool** | | [optional] [default to false] +**Id** | **long** | | [optional] +**PetId** | **long** | | [optional] +**Quantity** | **int** | | [optional] +**ShipDate** | **DateTime** | | [optional] +**Status** | **string** | Order Status | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterComposite.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterComposite.md new file mode 100644 index 000000000000..8985c59d094f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterComposite.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.OuterComposite + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MyBoolean** | **bool** | | [optional] +**MyNumber** | **decimal** | | [optional] +**MyString** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnum.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnum.md new file mode 100644 index 000000000000..36844bc4b175 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnum.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumDefaultValue.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumDefaultValue.md new file mode 100644 index 000000000000..351383f0aeae --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumDefaultValue.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumDefaultValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumInteger.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumInteger.md new file mode 100644 index 000000000000..1013b5b19565 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumInteger.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumInteger + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumIntegerDefaultValue.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumIntegerDefaultValue.md new file mode 100644 index 000000000000..55e314e3102d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumIntegerDefaultValue.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumIntegerDefaultValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumTest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumTest.md new file mode 100644 index 000000000000..b99d27c2c2e7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/OuterEnumTest.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.OuterEnumTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ParentPet.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ParentPet.md new file mode 100644 index 000000000000..bdf570056372 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ParentPet.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ParentPet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**PetType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pet.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pet.md new file mode 100644 index 000000000000..4f019b613bd7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pet.md @@ -0,0 +1,15 @@ +# Org.OpenAPITools.Model.Pet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | +**PhotoUrls** | **List<string>** | | +**Category** | [**Category**](Category.md) | | [optional] +**Id** | **long** | | [optional] +**Status** | **string** | pet status in the store | [optional] +**Tags** | [**List<Tag>**](Tag.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pig.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pig.md new file mode 100644 index 000000000000..fd7bb9359ac4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Pig.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Pig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/PolymorphicProperty.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/PolymorphicProperty.md new file mode 100644 index 000000000000..4507ec41cd51 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/PolymorphicProperty.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.PolymorphicProperty + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Quadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Quadrilateral.md new file mode 100644 index 000000000000..fbbf4f81cec6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Quadrilateral.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Quadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/QuadrilateralInterface.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/QuadrilateralInterface.md new file mode 100644 index 000000000000..756ba09c6ddf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/QuadrilateralInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.QuadrilateralInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ReadOnlyFirst.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ReadOnlyFirst.md new file mode 100644 index 000000000000..afaf2ee4fb6c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ReadOnlyFirst.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ReadOnlyFirst + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Bar** | **string** | | [optional] [readonly] +**Baz** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RequiredClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RequiredClass.md new file mode 100644 index 000000000000..7460783c91d1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RequiredClass.md @@ -0,0 +1,53 @@ +# Org.OpenAPITools.Model.RequiredClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**RequiredNotNullableDateProp** | **DateTime** | | +**RequiredNotnullableArrayOfString** | **List<string>** | | +**RequiredNotnullableBooleanProp** | **bool** | | +**RequiredNotnullableDatetimeProp** | **DateTime** | | +**RequiredNotnullableEnumInteger** | **int** | | +**RequiredNotnullableEnumIntegerOnly** | **int** | | +**RequiredNotnullableEnumString** | **string** | | +**RequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNotnullableStringProp** | **string** | | +**RequiredNotnullableUuid** | **Guid** | | +**RequiredNotnullableintegerProp** | **int** | | +**NotRequiredNotnullableDateProp** | **DateTime** | | [optional] +**NotRequiredNotnullableintegerProp** | **int** | | [optional] +**NotRequiredNullableDateProp** | **DateTime** | | [optional] +**NotRequiredNullableIntegerProp** | **int** | | [optional] +**NotrequiredNotnullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNotnullableBooleanProp** | **bool** | | [optional] +**NotrequiredNotnullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNotnullableEnumInteger** | **int** | | [optional] +**NotrequiredNotnullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNotnullableEnumString** | **string** | | [optional] +**NotrequiredNotnullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNotnullableStringProp** | **string** | | [optional] +**NotrequiredNotnullableUuid** | **Guid** | | [optional] +**NotrequiredNullableArrayOfString** | **List<string>** | | [optional] +**NotrequiredNullableBooleanProp** | **bool** | | [optional] +**NotrequiredNullableDatetimeProp** | **DateTime** | | [optional] +**NotrequiredNullableEnumInteger** | **int** | | [optional] +**NotrequiredNullableEnumIntegerOnly** | **int** | | [optional] +**NotrequiredNullableEnumString** | **string** | | [optional] +**NotrequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional] +**NotrequiredNullableStringProp** | **string** | | [optional] +**NotrequiredNullableUuid** | **Guid** | | [optional] +**RequiredNullableArrayOfString** | **List<string>** | | +**RequiredNullableBooleanProp** | **bool** | | +**RequiredNullableDateProp** | **DateTime** | | +**RequiredNullableDatetimeProp** | **DateTime** | | +**RequiredNullableEnumInteger** | **int** | | +**RequiredNullableEnumIntegerOnly** | **int** | | +**RequiredNullableEnumString** | **string** | | +**RequiredNullableIntegerProp** | **int** | | +**RequiredNullableOuterEnumDefaultValue** | **OuterEnumDefaultValue** | | +**RequiredNullableStringProp** | **string** | | +**RequiredNullableUuid** | **Guid** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Return.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Return.md new file mode 100644 index 000000000000..ad96a170bbbb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Return.md @@ -0,0 +1,14 @@ +# Org.OpenAPITools.Model.Return +Model for testing reserved words + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Lock** | **string** | | +**Abstract** | **string** | | +**VarReturn** | **int** | | [optional] +**Unsafe** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHash.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHash.md new file mode 100644 index 000000000000..d92c01de9ef7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHash.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.RolesReportsHash +Role report Hash + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Role** | [**RolesReportsHashRole**](RolesReportsHashRole.md) | | [optional] +**RoleUuid** | **Guid** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHashRole.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHashRole.md new file mode 100644 index 000000000000..760f77b30e78 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/RolesReportsHashRole.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.RolesReportsHashRole + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ScaleneTriangle.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ScaleneTriangle.md new file mode 100644 index 000000000000..d3f15354bccc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ScaleneTriangle.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ScaleneTriangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Shape.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Shape.md new file mode 100644 index 000000000000..ae75c5925401 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Shape.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Shape + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeInterface.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeInterface.md new file mode 100644 index 000000000000..882d31868305 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ShapeInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeOrNull.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeOrNull.md new file mode 100644 index 000000000000..7fcd31a3a5e1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ShapeOrNull.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.ShapeOrNull +The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SimpleQuadrilateral.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SimpleQuadrilateral.md new file mode 100644 index 000000000000..a9c7f93b67ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SimpleQuadrilateral.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.SimpleQuadrilateral + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**QuadrilateralType** | **string** | | +**ShapeType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SpecialModelName.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SpecialModelName.md new file mode 100644 index 000000000000..890bcd923dee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/SpecialModelName.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.SpecialModelName + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**VarSpecialModelName** | **string** | | [optional] +**SpecialPropertyName** | **long** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Tag.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Tag.md new file mode 100644 index 000000000000..2b2d9674d619 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Tag.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Tag + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long** | | [optional] +**Name** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordList.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordList.md new file mode 100644 index 000000000000..5c5eb22d9a8a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordList.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestCollectionEndingWithWordList + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Value** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordListObject.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordListObject.md new file mode 100644 index 000000000000..cfa933cc576e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestCollectionEndingWithWordListObject.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestCollectionEndingWithWordListObject + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TestCollectionEndingWithWordList** | [**List<TestCollectionEndingWithWordList>**](TestCollectionEndingWithWordList.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md new file mode 100644 index 000000000000..b6f9fc948474 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestInlineFreeformAdditionalPropertiesRequest.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestInlineFreeformAdditionalPropertiesRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**SomeProperty** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Triangle.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Triangle.md new file mode 100644 index 000000000000..e15109911958 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Triangle.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.Triangle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TriangleInterface.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TriangleInterface.md new file mode 100644 index 000000000000..4127c08b14f3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TriangleInterface.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TriangleInterface + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**TriangleType** | **string** | | + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/User.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/User.md new file mode 100644 index 000000000000..b5700f1c75d9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/User.md @@ -0,0 +1,21 @@ +# Org.OpenAPITools.Model.User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**AnyTypeProp** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 | [optional] +**AnyTypePropNullable** | **Object** | test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. | [optional] +**Email** | **string** | | [optional] +**FirstName** | **string** | | [optional] +**Id** | **long** | | [optional] +**LastName** | **string** | | [optional] +**ObjectWithNoDeclaredProps** | **Object** | test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. | [optional] +**ObjectWithNoDeclaredPropsNullable** | **Object** | test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. | [optional] +**Password** | **string** | | [optional] +**Phone** | **string** | | [optional] +**UserStatus** | **int** | User Status | [optional] +**Username** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Whale.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Whale.md new file mode 100644 index 000000000000..1c633fdce61b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Whale.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Whale + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**HasBaleen** | **bool** | | [optional] +**HasTeeth** | **bool** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Zebra.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Zebra.md new file mode 100644 index 000000000000..aef3866b92c9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Zebra.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.Zebra + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ClassName** | **string** | | +**Type** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnum.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnum.md new file mode 100644 index 000000000000..cb71966c4c81 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnum.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.ZeroBasedEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnumClass.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnumClass.md new file mode 100644 index 000000000000..614d00cbe878 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/ZeroBasedEnumClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.ZeroBasedEnumClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ZeroBasedEnum** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs new file mode 100644 index 000000000000..cf82a3e39bd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/AnotherFakeApiTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing AnotherFakeApi + /// + public sealed class AnotherFakeApiTests : ApiTestsBase + { + private readonly IAnotherFakeApi _instance; + + public AnotherFakeApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test Call123TestSpecialTags + /// + [Fact (Skip = "not implemented")] + public async Task Call123TestSpecialTagsAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.Call123TestSpecialTagsAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..c178aac4eabe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,81 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + string apiKeyTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + ApiKeyToken apiKeyToken1 = new ApiKeyToken(apiKeyTokenValue1, ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + string apiKeyTokenValue2 = context.Configuration[""] ?? throw new Exception("Token not found."); + ApiKeyToken apiKeyToken2 = new ApiKeyToken(apiKeyTokenValue2, ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + string bearerTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + BearerToken bearerToken1 = new BearerToken(bearerTokenValue1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + string basicTokenUsername1 = context.Configuration[""] ?? throw new Exception("Username not found."); + string basicTokenPassword1 = context.Configuration[""] ?? throw new Exception("Password not found."); + BasicToken basicToken1 = new BasicToken(basicTokenUsername1, basicTokenPassword1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + string oauthTokenValue1 = context.Configuration[""] ?? throw new Exception("Token not found."); + OAuthToken oauthToken1 = new OAuthToken(oauthTokenValue1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..88cf05ba9ed8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test FooGet + /// + [Fact (Skip = "not implemented")] + public async Task FooGetAsyncTest() + { + var response = await _instance.FooGetAsync(); + var model = response.Default(); + Assert.IsType(model); + } + + /// + /// Test GetCountry + /// + [Fact (Skip = "not implemented")] + public async Task GetCountryAsyncTest() + { + string country = default; + await _instance.GetCountryAsync(country); + } + + /// + /// Test Hello + /// + [Fact (Skip = "not implemented")] + public async Task HelloAsyncTest() + { + var response = await _instance.HelloAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test RolesReportGet + /// + [Fact (Skip = "not implemented")] + public async Task RolesReportGetAsyncTest() + { + var response = await _instance.RolesReportGetAsync(); + var model = response.Ok(); + Assert.IsType>>(model); + } + + /// + /// Test Test + /// + [Fact (Skip = "not implemented")] + public async Task TestAsyncTest() + { + var response = await _instance.TestAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..bbccd77b29c1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,243 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken); + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + ApiKeyToken apiKeyToken1 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken1); + + ApiKeyToken apiKeyToken2 = new ApiKeyToken("", ClientUtils.ApiKeyHeader.Api_key_query, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(apiKeyToken2); + + BearerToken bearerToken1 = new BearerToken("", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(bearerToken1); + + BasicToken basicToken1 = new BasicToken("", "", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(basicToken1); + + HttpSigningConfiguration config1 = new HttpSigningConfiguration("", "", null, new List(), HashAlgorithmName.SHA256, "", 0); + HttpSignatureToken httpSignatureToken1 = new HttpSignatureToken(config1, timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(httpSignatureToken1); + + OAuthToken oauthToken1 = new OAuthToken("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var anotherFakeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var anotherFakeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var anotherFakeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var anotherFakeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(anotherFakeApi.HttpClient.BaseAddress != null); + + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + + var fakeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeApi.HttpClient.BaseAddress != null); + + var fakeClassnameTags123Api = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(fakeClassnameTags123Api.HttpClient.BaseAddress != null); + + var petApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(petApi.HttpClient.BaseAddress != null); + + var storeApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(storeApi.HttpClient.BaseAddress != null); + + var userApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(userApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs new file mode 100644 index 000000000000..ee61aa929639 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -0,0 +1,281 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing FakeApi + /// + public sealed class FakeApiTests : ApiTestsBase + { + private readonly IFakeApi _instance; + + public FakeApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test FakeHealthGet + /// + [Fact (Skip = "not implemented")] + public async Task FakeHealthGetAsyncTest() + { + var response = await _instance.FakeHealthGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterBooleanSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterBooleanSerializeAsyncTest() + { + Client.Option body = default; + var response = await _instance.FakeOuterBooleanSerializeAsync(body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterCompositeSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterCompositeSerializeAsyncTest() + { + Client.Option outerComposite = default; + var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterNumberSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterNumberSerializeAsyncTest() + { + Client.Option body = default; + var response = await _instance.FakeOuterNumberSerializeAsync(body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test FakeOuterStringSerialize + /// + [Fact (Skip = "not implemented")] + public async Task FakeOuterStringSerializeAsyncTest() + { + Guid requiredStringUuid = default; + Client.Option body = default; + var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetArrayOfEnums + /// + [Fact (Skip = "not implemented")] + public async Task GetArrayOfEnumsAsyncTest() + { + var response = await _instance.GetArrayOfEnumsAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test TestAdditionalPropertiesReference + /// + [Fact (Skip = "not implemented")] + public async Task TestAdditionalPropertiesReferenceAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestAdditionalPropertiesReferenceAsync(requestBody); + } + + /// + /// Test TestBodyWithFileSchema + /// + [Fact (Skip = "not implemented")] + public async Task TestBodyWithFileSchemaAsyncTest() + { + FileSchemaTestClass fileSchemaTestClass = default; + await _instance.TestBodyWithFileSchemaAsync(fileSchemaTestClass); + } + + /// + /// Test TestBodyWithQueryParams + /// + [Fact (Skip = "not implemented")] + public async Task TestBodyWithQueryParamsAsyncTest() + { + User user = default; + string query = default; + await _instance.TestBodyWithQueryParamsAsync(user, query); + } + + /// + /// Test TestClientModel + /// + [Fact (Skip = "not implemented")] + public async Task TestClientModelAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.TestClientModelAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test TestEndpointParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestEndpointParametersAsyncTest() + { + byte[] varByte = default; + decimal number = default; + double varDouble = default; + string patternWithoutDelimiter = default; + Client.Option date = default; + Client.Option binary = default; + Client.Option varFloat = default; + Client.Option integer = default; + Client.Option int32 = default; + Client.Option int64 = default; + Client.Option varString = default; + Client.Option password = default; + Client.Option callback = default; + Client.Option dateTime = default; + await _instance.TestEndpointParametersAsync(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + } + + /// + /// Test TestEnumParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestEnumParametersAsyncTest() + { + Client.Option> enumHeaderStringArray = default; + Client.Option> enumQueryStringArray = default; + Client.Option enumQueryDouble = default; + Client.Option enumQueryInteger = default; + Client.Option> enumFormStringArray = default; + Client.Option enumHeaderString = default; + Client.Option enumQueryString = default; + Client.Option enumFormString = default; + await _instance.TestEnumParametersAsync(enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + } + + /// + /// Test TestGroupParameters + /// + [Fact (Skip = "not implemented")] + public async Task TestGroupParametersAsyncTest() + { + bool requiredBooleanGroup = default; + int requiredStringGroup = default; + long requiredInt64Group = default; + Client.Option booleanGroup = default; + Client.Option stringGroup = default; + Client.Option int64Group = default; + await _instance.TestGroupParametersAsync(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + } + + /// + /// Test TestInlineAdditionalProperties + /// + [Fact (Skip = "not implemented")] + public async Task TestInlineAdditionalPropertiesAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestInlineAdditionalPropertiesAsync(requestBody); + } + + /// + /// Test TestInlineFreeformAdditionalProperties + /// + [Fact (Skip = "not implemented")] + public async Task TestInlineFreeformAdditionalPropertiesAsyncTest() + { + TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest = default; + await _instance.TestInlineFreeformAdditionalPropertiesAsync(testInlineFreeformAdditionalPropertiesRequest); + } + + /// + /// Test TestJsonFormData + /// + [Fact (Skip = "not implemented")] + public async Task TestJsonFormDataAsyncTest() + { + string param = default; + string param2 = default; + await _instance.TestJsonFormDataAsync(param, param2); + } + + /// + /// Test TestQueryParameterCollectionFormat + /// + [Fact (Skip = "not implemented")] + public async Task TestQueryParameterCollectionFormatAsyncTest() + { + List pipe = default; + List ioutil = default; + List http = default; + List url = default; + List context = default; + string requiredNotNullable = default; + string requiredNullable = default; + Client.Option notRequiredNotNullable = default; + Client.Option notRequiredNullable = default; + await _instance.TestQueryParameterCollectionFormatAsync(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + } + + /// + /// Test TestStringMapReference + /// + [Fact (Skip = "not implemented")] + public async Task TestStringMapReferenceAsyncTest() + { + Dictionary requestBody = default; + await _instance.TestStringMapReferenceAsync(requestBody); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs new file mode 100644 index 000000000000..5964bf6e51d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeClassnameTags123ApiTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing FakeClassnameTags123Api + /// + public sealed class FakeClassnameTags123ApiTests : ApiTestsBase + { + private readonly IFakeClassnameTags123Api _instance; + + public FakeClassnameTags123ApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test TestClassname + /// + [Fact (Skip = "not implemented")] + public async Task TestClassnameAsyncTest() + { + ModelClient modelClient = default; + var response = await _instance.TestClassnameAsync(modelClient); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs new file mode 100644 index 000000000000..c5e6e7e2f9d2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/PetApiTests.cs @@ -0,0 +1,160 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing PetApi + /// + public sealed class PetApiTests : ApiTestsBase + { + private readonly IPetApi _instance; + + public PetApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test AddPet + /// + [Fact (Skip = "not implemented")] + public async Task AddPetAsyncTest() + { + Pet pet = default; + await _instance.AddPetAsync(pet); + } + + /// + /// Test DeletePet + /// + [Fact (Skip = "not implemented")] + public async Task DeletePetAsyncTest() + { + long petId = default; + Client.Option apiKey = default; + await _instance.DeletePetAsync(petId, apiKey); + } + + /// + /// Test FindPetsByStatus + /// + [Fact (Skip = "not implemented")] + public async Task FindPetsByStatusAsyncTest() + { + List status = default; + var response = await _instance.FindPetsByStatusAsync(status); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test FindPetsByTags + /// + [Fact (Skip = "not implemented")] + public async Task FindPetsByTagsAsyncTest() + { + List tags = default; + var response = await _instance.FindPetsByTagsAsync(tags); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test GetPetById + /// + [Fact (Skip = "not implemented")] + public async Task GetPetByIdAsyncTest() + { + long petId = default; + var response = await _instance.GetPetByIdAsync(petId); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test UpdatePet + /// + [Fact (Skip = "not implemented")] + public async Task UpdatePetAsyncTest() + { + Pet pet = default; + await _instance.UpdatePetAsync(pet); + } + + /// + /// Test UpdatePetWithForm + /// + [Fact (Skip = "not implemented")] + public async Task UpdatePetWithFormAsyncTest() + { + long petId = default; + Client.Option name = default; + Client.Option status = default; + await _instance.UpdatePetWithFormAsync(petId, name, status); + } + + /// + /// Test UploadFile + /// + [Fact (Skip = "not implemented")] + public async Task UploadFileAsyncTest() + { + long petId = default; + Client.Option file = default; + Client.Option additionalMetadata = default; + var response = await _instance.UploadFileAsync(petId, file, additionalMetadata); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test UploadFileWithRequiredFile + /// + [Fact (Skip = "not implemented")] + public async Task UploadFileWithRequiredFileAsyncTest() + { + System.IO.Stream requiredFile = default; + long petId = default; + Client.Option additionalMetadata = default; + var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs new file mode 100644 index 000000000000..1b75e3417005 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/StoreApiTests.cs @@ -0,0 +1,98 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing StoreApi + /// + public sealed class StoreApiTests : ApiTestsBase + { + private readonly IStoreApi _instance; + + public StoreApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test DeleteOrder + /// + [Fact (Skip = "not implemented")] + public async Task DeleteOrderAsyncTest() + { + string orderId = default; + await _instance.DeleteOrderAsync(orderId); + } + + /// + /// Test GetInventory + /// + [Fact (Skip = "not implemented")] + public async Task GetInventoryAsyncTest() + { + var response = await _instance.GetInventoryAsync(); + var model = response.Ok(); + Assert.IsType>(model); + } + + /// + /// Test GetOrderById + /// + [Fact (Skip = "not implemented")] + public async Task GetOrderByIdAsyncTest() + { + long orderId = default; + var response = await _instance.GetOrderByIdAsync(orderId); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test PlaceOrder + /// + [Fact (Skip = "not implemented")] + public async Task PlaceOrderAsyncTest() + { + Order order = default; + var response = await _instance.PlaceOrderAsync(order); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/UserApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/UserApiTests.cs new file mode 100644 index 000000000000..38ee1125438a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/UserApiTests.cs @@ -0,0 +1,138 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing UserApi + /// + public sealed class UserApiTests : ApiTestsBase + { + private readonly IUserApi _instance; + + public UserApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test CreateUser + /// + [Fact (Skip = "not implemented")] + public async Task CreateUserAsyncTest() + { + User user = default; + await _instance.CreateUserAsync(user); + } + + /// + /// Test CreateUsersWithArrayInput + /// + [Fact (Skip = "not implemented")] + public async Task CreateUsersWithArrayInputAsyncTest() + { + List user = default; + await _instance.CreateUsersWithArrayInputAsync(user); + } + + /// + /// Test CreateUsersWithListInput + /// + [Fact (Skip = "not implemented")] + public async Task CreateUsersWithListInputAsyncTest() + { + List user = default; + await _instance.CreateUsersWithListInputAsync(user); + } + + /// + /// Test DeleteUser + /// + [Fact (Skip = "not implemented")] + public async Task DeleteUserAsyncTest() + { + string username = default; + await _instance.DeleteUserAsync(username); + } + + /// + /// Test GetUserByName + /// + [Fact (Skip = "not implemented")] + public async Task GetUserByNameAsyncTest() + { + string username = default; + var response = await _instance.GetUserByNameAsync(username); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test LoginUser + /// + [Fact (Skip = "not implemented")] + public async Task LoginUserAsyncTest() + { + string username = default; + string password = default; + var response = await _instance.LoginUserAsync(username, password); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test LogoutUser + /// + [Fact (Skip = "not implemented")] + public async Task LogoutUserAsyncTest() + { + await _instance.LogoutUserAsync(); + } + + /// + /// Test UpdateUser + /// + [Fact (Skip = "not implemented")] + public async Task UpdateUserAsyncTest() + { + User user = default; + string username = default; + await _instance.UpdateUserAsync(user, username); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs new file mode 100644 index 000000000000..adbf639fd720 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityOutputElementRepresentationTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ActivityOutputElementRepresentation + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ActivityOutputElementRepresentationTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ActivityOutputElementRepresentation + //private ActivityOutputElementRepresentation instance; + + public ActivityOutputElementRepresentationTests() + { + // TODO uncomment below to create an instance of ActivityOutputElementRepresentation + //instance = new ActivityOutputElementRepresentation(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ActivityOutputElementRepresentation + /// + [Fact] + public void ActivityOutputElementRepresentationInstanceTest() + { + // TODO uncomment below to test "IsType" ActivityOutputElementRepresentation + //Assert.IsType(instance); + } + + /// + /// Test the property 'Prop1' + /// + [Fact] + public void Prop1Test() + { + // TODO unit test for the property 'Prop1' + } + + /// + /// Test the property 'Prop2' + /// + [Fact] + public void Prop2Test() + { + // TODO unit test for the property 'Prop2' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityTests.cs new file mode 100644 index 000000000000..6cc2927eaaf3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ActivityTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Activity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Activity + //private Activity instance; + + public ActivityTests() + { + // TODO uncomment below to create an instance of Activity + //instance = new Activity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Activity + /// + [Fact] + public void ActivityInstanceTest() + { + // TODO uncomment below to test "IsType" Activity + //Assert.IsType(instance); + } + + /// + /// Test the property 'ActivityOutputs' + /// + [Fact] + public void ActivityOutputsTest() + { + // TODO unit test for the property 'ActivityOutputs' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs new file mode 100644 index 000000000000..e157b477193e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AdditionalPropertiesClassTests.cs @@ -0,0 +1,128 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing AdditionalPropertiesClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AdditionalPropertiesClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for AdditionalPropertiesClass + //private AdditionalPropertiesClass instance; + + public AdditionalPropertiesClassTests() + { + // TODO uncomment below to create an instance of AdditionalPropertiesClass + //instance = new AdditionalPropertiesClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of AdditionalPropertiesClass + /// + [Fact] + public void AdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsType" AdditionalPropertiesClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'Anytype1' + /// + [Fact] + public void Anytype1Test() + { + // TODO unit test for the property 'Anytype1' + } + + /// + /// Test the property 'EmptyMap' + /// + [Fact] + public void EmptyMapTest() + { + // TODO unit test for the property 'EmptyMap' + } + + /// + /// Test the property 'MapOfMapProperty' + /// + [Fact] + public void MapOfMapPropertyTest() + { + // TODO unit test for the property 'MapOfMapProperty' + } + + /// + /// Test the property 'MapProperty' + /// + [Fact] + public void MapPropertyTest() + { + // TODO unit test for the property 'MapProperty' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype1' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype1Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype1' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype2' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype2Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype2' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesAnytype3' + /// + [Fact] + public void MapWithUndeclaredPropertiesAnytype3Test() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesAnytype3' + } + + /// + /// Test the property 'MapWithUndeclaredPropertiesString' + /// + [Fact] + public void MapWithUndeclaredPropertiesStringTest() + { + // TODO unit test for the property 'MapWithUndeclaredPropertiesString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AnimalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AnimalTests.cs new file mode 100644 index 000000000000..1db9725afb85 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AnimalTests.cs @@ -0,0 +1,94 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Animal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AnimalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Animal + //private Animal instance; + + public AnimalTests() + { + // TODO uncomment below to create an instance of Animal + //instance = new Animal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Animal + /// + [Fact] + public void AnimalInstanceTest() + { + // TODO uncomment below to test "IsType" Animal + //Assert.IsType(instance); + } + + /// + /// Test deserialize a Cat from type Animal + /// + [Fact] + public void CatDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Cat from type Animal + //Assert.IsType(JsonConvert.DeserializeObject(new Cat().ToJson())); + } + + /// + /// Test deserialize a Dog from type Animal + /// + [Fact] + public void DogDeserializeFromAnimalTest() + { + // TODO uncomment below to test deserialize a Dog from type Animal + //Assert.IsType(JsonConvert.DeserializeObject(new Dog().ToJson())); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs new file mode 100644 index 000000000000..c296a82116a7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ApiResponseTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ApiResponse + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ApiResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ApiResponse + //private ApiResponse instance; + + public ApiResponseTests() + { + // TODO uncomment below to create an instance of ApiResponse + //instance = new ApiResponse(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ApiResponse + /// + [Fact] + public void ApiResponseInstanceTest() + { + // TODO uncomment below to test "IsType" ApiResponse + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Message' + /// + [Fact] + public void MessageTest() + { + // TODO unit test for the property 'Message' + } + + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs new file mode 100644 index 000000000000..d698ee445048 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleReqTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing AppleReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for AppleReq + //private AppleReq instance; + + public AppleReqTests() + { + // TODO uncomment below to create an instance of AppleReq + //instance = new AppleReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of AppleReq + /// + [Fact] + public void AppleReqInstanceTest() + { + // TODO uncomment below to test "IsType" AppleReq + //Assert.IsType(instance); + } + + /// + /// Test the property 'Cultivar' + /// + [Fact] + public void CultivarTest() + { + // TODO unit test for the property 'Cultivar' + } + + /// + /// Test the property 'Mealy' + /// + [Fact] + public void MealyTest() + { + // TODO unit test for the property 'Mealy' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleTests.cs new file mode 100644 index 000000000000..c7c8ccd47c11 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/AppleTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Apple + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class AppleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Apple + //private Apple instance; + + public AppleTests() + { + // TODO uncomment below to create an instance of Apple + //instance = new Apple(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Apple + /// + [Fact] + public void AppleInstanceTest() + { + // TODO uncomment below to test "IsType" Apple + //Assert.IsType(instance); + } + + /// + /// Test the property 'ColorCode' + /// + [Fact] + public void ColorCodeTest() + { + // TODO unit test for the property 'ColorCode' + } + + /// + /// Test the property 'Cultivar' + /// + [Fact] + public void CultivarTest() + { + // TODO unit test for the property 'Cultivar' + } + + /// + /// Test the property 'Origin' + /// + [Fact] + public void OriginTest() + { + // TODO unit test for the property 'Origin' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs new file mode 100644 index 000000000000..29fe9cfb1d47 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfArrayOfNumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayOfArrayOfNumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayOfArrayOfNumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayOfArrayOfNumberOnly + //private ArrayOfArrayOfNumberOnly instance; + + public ArrayOfArrayOfNumberOnlyTests() + { + // TODO uncomment below to create an instance of ArrayOfArrayOfNumberOnly + //instance = new ArrayOfArrayOfNumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayOfArrayOfNumberOnly + /// + [Fact] + public void ArrayOfArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayOfArrayOfNumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayArrayNumber' + /// + [Fact] + public void ArrayArrayNumberTest() + { + // TODO unit test for the property 'ArrayArrayNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs new file mode 100644 index 000000000000..2b0956c0b984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayOfNumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayOfNumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayOfNumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayOfNumberOnly + //private ArrayOfNumberOnly instance; + + public ArrayOfNumberOnlyTests() + { + // TODO uncomment below to create an instance of ArrayOfNumberOnly + //instance = new ArrayOfNumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayOfNumberOnly + /// + [Fact] + public void ArrayOfNumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayOfNumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayNumber' + /// + [Fact] + public void ArrayNumberTest() + { + // TODO unit test for the property 'ArrayNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs new file mode 100644 index 000000000000..3b01d0b7abbc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ArrayTestTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ArrayTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ArrayTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ArrayTest + //private ArrayTest instance; + + public ArrayTestTests() + { + // TODO uncomment below to create an instance of ArrayTest + //instance = new ArrayTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ArrayTest + /// + [Fact] + public void ArrayTestInstanceTest() + { + // TODO uncomment below to test "IsType" ArrayTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayArrayOfInteger' + /// + [Fact] + public void ArrayArrayOfIntegerTest() + { + // TODO unit test for the property 'ArrayArrayOfInteger' + } + + /// + /// Test the property 'ArrayArrayOfModel' + /// + [Fact] + public void ArrayArrayOfModelTest() + { + // TODO unit test for the property 'ArrayArrayOfModel' + } + + /// + /// Test the property 'ArrayOfString' + /// + [Fact] + public void ArrayOfStringTest() + { + // TODO unit test for the property 'ArrayOfString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs new file mode 100644 index 000000000000..1e54c1f3e41d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaReqTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing BananaReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for BananaReq + //private BananaReq instance; + + public BananaReqTests() + { + // TODO uncomment below to create an instance of BananaReq + //instance = new BananaReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of BananaReq + /// + [Fact] + public void BananaReqInstanceTest() + { + // TODO uncomment below to test "IsType" BananaReq + //Assert.IsType(instance); + } + + /// + /// Test the property 'LengthCm' + /// + [Fact] + public void LengthCmTest() + { + // TODO unit test for the property 'LengthCm' + } + + /// + /// Test the property 'Sweet' + /// + [Fact] + public void SweetTest() + { + // TODO unit test for the property 'Sweet' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaTests.cs new file mode 100644 index 000000000000..5a88e9dabbdf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BananaTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Banana + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BananaTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Banana + //private Banana instance; + + public BananaTests() + { + // TODO uncomment below to create an instance of Banana + //instance = new Banana(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Banana + /// + [Fact] + public void BananaInstanceTest() + { + // TODO uncomment below to test "IsType" Banana + //Assert.IsType(instance); + } + + /// + /// Test the property 'LengthCm' + /// + [Fact] + public void LengthCmTest() + { + // TODO unit test for the property 'LengthCm' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs new file mode 100644 index 000000000000..4ffd6c2c0c87 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/BasquePigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing BasquePig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class BasquePigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for BasquePig + //private BasquePig instance; + + public BasquePigTests() + { + // TODO uncomment below to create an instance of BasquePig + //instance = new BasquePig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of BasquePig + /// + [Fact] + public void BasquePigInstanceTest() + { + // TODO uncomment below to test "IsType" BasquePig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs new file mode 100644 index 000000000000..d0391fb47f8f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CapitalizationTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Capitalization + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CapitalizationTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Capitalization + //private Capitalization instance; + + public CapitalizationTests() + { + // TODO uncomment below to create an instance of Capitalization + //instance = new Capitalization(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Capitalization + /// + [Fact] + public void CapitalizationInstanceTest() + { + // TODO uncomment below to test "IsType" Capitalization + //Assert.IsType(instance); + } + + /// + /// Test the property 'ATT_NAME' + /// + [Fact] + public void ATT_NAMETest() + { + // TODO unit test for the property 'ATT_NAME' + } + + /// + /// Test the property 'CapitalCamel' + /// + [Fact] + public void CapitalCamelTest() + { + // TODO unit test for the property 'CapitalCamel' + } + + /// + /// Test the property 'CapitalSnake' + /// + [Fact] + public void CapitalSnakeTest() + { + // TODO unit test for the property 'CapitalSnake' + } + + /// + /// Test the property 'SCAETHFlowPoints' + /// + [Fact] + public void SCAETHFlowPointsTest() + { + // TODO unit test for the property 'SCAETHFlowPoints' + } + + /// + /// Test the property 'SmallCamel' + /// + [Fact] + public void SmallCamelTest() + { + // TODO unit test for the property 'SmallCamel' + } + + /// + /// Test the property 'SmallSnake' + /// + [Fact] + public void SmallSnakeTest() + { + // TODO unit test for the property 'SmallSnake' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CatTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CatTests.cs new file mode 100644 index 000000000000..a5d4bf43bbfd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CatTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Cat + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CatTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Cat + //private Cat instance; + + public CatTests() + { + // TODO uncomment below to create an instance of Cat + //instance = new Cat(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Cat + /// + [Fact] + public void CatInstanceTest() + { + // TODO uncomment below to test "IsType" Cat + //Assert.IsType(instance); + } + + /// + /// Test the property 'Declawed' + /// + [Fact] + public void DeclawedTest() + { + // TODO unit test for the property 'Declawed' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CategoryTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CategoryTests.cs new file mode 100644 index 000000000000..7fe8f333c81a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CategoryTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Category + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CategoryTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Category + //private Category instance; + + public CategoryTests() + { + // TODO uncomment below to create an instance of Category + //instance = new Category(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Category + /// + [Fact] + public void CategoryInstanceTest() + { + // TODO uncomment below to test "IsType" Category + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs new file mode 100644 index 000000000000..2c02364a9f76 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ChildCatTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ChildCat + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ChildCatTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ChildCat + //private ChildCat instance; + + public ChildCatTests() + { + // TODO uncomment below to create an instance of ChildCat + //instance = new ChildCat(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ChildCat + /// + [Fact] + public void ChildCatInstanceTest() + { + // TODO uncomment below to test "IsType" ChildCat + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + + /// + /// Test the property 'PetType' + /// + [Fact] + public void PetTypeTest() + { + // TODO unit test for the property 'PetType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs new file mode 100644 index 000000000000..a866bfbe242d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ClassModelTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ClassModel + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ClassModelTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ClassModel + //private ClassModel instance; + + public ClassModelTests() + { + // TODO uncomment below to create an instance of ClassModel + //instance = new ClassModel(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ClassModel + /// + [Fact] + public void ClassModelInstanceTest() + { + // TODO uncomment below to test "IsType" ClassModel + //Assert.IsType(instance); + } + + /// + /// Test the property 'Class' + /// + [Fact] + public void ClassTest() + { + // TODO unit test for the property 'Class' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs new file mode 100644 index 000000000000..a7a864154acf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ComplexQuadrilateralTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ComplexQuadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ComplexQuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ComplexQuadrilateral + //private ComplexQuadrilateral instance; + + public ComplexQuadrilateralTests() + { + // TODO uncomment below to create an instance of ComplexQuadrilateral + //instance = new ComplexQuadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ComplexQuadrilateral + /// + [Fact] + public void ComplexQuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" ComplexQuadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs new file mode 100644 index 000000000000..e7c505b5136d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DanishPigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DanishPig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DanishPigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DanishPig + //private DanishPig instance; + + public DanishPigTests() + { + // TODO uncomment below to create an instance of DanishPig + //instance = new DanishPig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DanishPig + /// + [Fact] + public void DanishPigInstanceTest() + { + // TODO uncomment below to test "IsType" DanishPig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..83a4185e53d2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs new file mode 100644 index 000000000000..95e56f782da3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DeprecatedObjectTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DeprecatedObject + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DeprecatedObjectTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DeprecatedObject + //private DeprecatedObject instance; + + public DeprecatedObjectTests() + { + // TODO uncomment below to create an instance of DeprecatedObject + //instance = new DeprecatedObject(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DeprecatedObject + /// + [Fact] + public void DeprecatedObjectInstanceTest() + { + // TODO uncomment below to test "IsType" DeprecatedObject + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DogTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DogTests.cs new file mode 100644 index 000000000000..b8e8bca05384 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DogTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Dog + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DogTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Dog + //private Dog instance; + + public DogTests() + { + // TODO uncomment below to create an instance of Dog + //instance = new Dog(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Dog + /// + [Fact] + public void DogInstanceTest() + { + // TODO uncomment below to test "IsType" Dog + //Assert.IsType(instance); + } + + /// + /// Test the property 'Breed' + /// + [Fact] + public void BreedTest() + { + // TODO unit test for the property 'Breed' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DrawingTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DrawingTests.cs new file mode 100644 index 000000000000..a2de4a1b97b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/DrawingTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Drawing + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DrawingTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Drawing + //private Drawing instance; + + public DrawingTests() + { + // TODO uncomment below to create an instance of Drawing + //instance = new Drawing(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Drawing + /// + [Fact] + public void DrawingInstanceTest() + { + // TODO uncomment below to test "IsType" Drawing + //Assert.IsType(instance); + } + + /// + /// Test the property 'MainShape' + /// + [Fact] + public void MainShapeTest() + { + // TODO unit test for the property 'MainShape' + } + + /// + /// Test the property 'NullableShape' + /// + [Fact] + public void NullableShapeTest() + { + // TODO unit test for the property 'NullableShape' + } + + /// + /// Test the property 'ShapeOrNull' + /// + [Fact] + public void ShapeOrNullTest() + { + // TODO unit test for the property 'ShapeOrNull' + } + + /// + /// Test the property 'Shapes' + /// + [Fact] + public void ShapesTest() + { + // TODO unit test for the property 'Shapes' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs new file mode 100644 index 000000000000..c6fee27690b7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumArraysTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumArrays + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumArraysTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumArrays + //private EnumArrays instance; + + public EnumArraysTests() + { + // TODO uncomment below to create an instance of EnumArrays + //instance = new EnumArrays(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumArrays + /// + [Fact] + public void EnumArraysInstanceTest() + { + // TODO uncomment below to test "IsType" EnumArrays + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayEnum' + /// + [Fact] + public void ArrayEnumTest() + { + // TODO unit test for the property 'ArrayEnum' + } + + /// + /// Test the property 'JustSymbol' + /// + [Fact] + public void JustSymbolTest() + { + // TODO unit test for the property 'JustSymbol' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs new file mode 100644 index 000000000000..44dbbe4d324a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumClassTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumClass + //private EnumClass instance; + + public EnumClassTests() + { + // TODO uncomment below to create an instance of EnumClass + //instance = new EnumClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumClass + /// + [Fact] + public void EnumClassInstanceTest() + { + // TODO uncomment below to test "IsType" EnumClass + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs new file mode 100644 index 000000000000..3781eebbfcf2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EnumTestTests.cs @@ -0,0 +1,137 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EnumTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EnumTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EnumTest + //private EnumTest instance; + + public EnumTestTests() + { + // TODO uncomment below to create an instance of EnumTest + //instance = new EnumTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EnumTest + /// + [Fact] + public void EnumTestInstanceTest() + { + // TODO uncomment below to test "IsType" EnumTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'EnumStringRequired' + /// + [Fact] + public void EnumStringRequiredTest() + { + // TODO unit test for the property 'EnumStringRequired' + } + + /// + /// Test the property 'EnumInteger' + /// + [Fact] + public void EnumIntegerTest() + { + // TODO unit test for the property 'EnumInteger' + } + + /// + /// Test the property 'EnumIntegerOnly' + /// + [Fact] + public void EnumIntegerOnlyTest() + { + // TODO unit test for the property 'EnumIntegerOnly' + } + + /// + /// Test the property 'EnumNumber' + /// + [Fact] + public void EnumNumberTest() + { + // TODO unit test for the property 'EnumNumber' + } + + /// + /// Test the property 'EnumString' + /// + [Fact] + public void EnumStringTest() + { + // TODO unit test for the property 'EnumString' + } + + /// + /// Test the property 'OuterEnum' + /// + [Fact] + public void OuterEnumTest() + { + // TODO unit test for the property 'OuterEnum' + } + + /// + /// Test the property 'OuterEnumDefaultValue' + /// + [Fact] + public void OuterEnumDefaultValueTest() + { + // TODO unit test for the property 'OuterEnumDefaultValue' + } + + /// + /// Test the property 'OuterEnumInteger' + /// + [Fact] + public void OuterEnumIntegerTest() + { + // TODO unit test for the property 'OuterEnumInteger' + } + + /// + /// Test the property 'OuterEnumIntegerDefaultValue' + /// + [Fact] + public void OuterEnumIntegerDefaultValueTest() + { + // TODO unit test for the property 'OuterEnumIntegerDefaultValue' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs new file mode 100644 index 000000000000..f8d3daec3fe1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EquilateralTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EquilateralTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EquilateralTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EquilateralTriangle + //private EquilateralTriangle instance; + + public EquilateralTriangleTests() + { + // TODO uncomment below to create an instance of EquilateralTriangle + //instance = new EquilateralTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EquilateralTriangle + /// + [Fact] + public void EquilateralTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" EquilateralTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs new file mode 100644 index 000000000000..e2685848d5ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileSchemaTestClassTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FileSchemaTestClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FileSchemaTestClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FileSchemaTestClass + //private FileSchemaTestClass instance; + + public FileSchemaTestClassTests() + { + // TODO uncomment below to create an instance of FileSchemaTestClass + //instance = new FileSchemaTestClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FileSchemaTestClass + /// + [Fact] + public void FileSchemaTestClassInstanceTest() + { + // TODO uncomment below to test "IsType" FileSchemaTestClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'File' + /// + [Fact] + public void FileTest() + { + // TODO unit test for the property 'File' + } + + /// + /// Test the property 'Files' + /// + [Fact] + public void FilesTest() + { + // TODO unit test for the property 'Files' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileTests.cs new file mode 100644 index 000000000000..c305c5356b05 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FileTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing File + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FileTests : IDisposable + { + // TODO uncomment below to declare an instance variable for File + //private File instance; + + public FileTests() + { + // TODO uncomment below to create an instance of File + //instance = new File(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of File + /// + [Fact] + public void FileInstanceTest() + { + // TODO uncomment below to test "IsType" File + //Assert.IsType(instance); + } + + /// + /// Test the property 'SourceURI' + /// + [Fact] + public void SourceURITest() + { + // TODO unit test for the property 'SourceURI' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs new file mode 100644 index 000000000000..55086a7cf24b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooGetDefaultResponseTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FooGetDefaultResponse + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FooGetDefaultResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FooGetDefaultResponse + //private FooGetDefaultResponse instance; + + public FooGetDefaultResponseTests() + { + // TODO uncomment below to create an instance of FooGetDefaultResponse + //instance = new FooGetDefaultResponse(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FooGetDefaultResponse + /// + [Fact] + public void FooGetDefaultResponseInstanceTest() + { + // TODO uncomment below to test "IsType" FooGetDefaultResponse + //Assert.IsType(instance); + } + + /// + /// Test the property 'String' + /// + [Fact] + public void StringTest() + { + // TODO unit test for the property 'String' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooTests.cs new file mode 100644 index 000000000000..871506eeaac5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FooTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Foo + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FooTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Foo + //private Foo instance; + + public FooTests() + { + // TODO uncomment below to create an instance of Foo + //instance = new Foo(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Foo + /// + [Fact] + public void FooInstanceTest() + { + // TODO uncomment below to test "IsType" Foo + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs new file mode 100644 index 000000000000..b658f317f1ce --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FormatTestTests.cs @@ -0,0 +1,227 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FormatTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FormatTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FormatTest + //private FormatTest instance; + + public FormatTestTests() + { + // TODO uncomment below to create an instance of FormatTest + //instance = new FormatTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FormatTest + /// + [Fact] + public void FormatTestInstanceTest() + { + // TODO uncomment below to test "IsType" FormatTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'Byte' + /// + [Fact] + public void ByteTest() + { + // TODO unit test for the property 'Byte' + } + + /// + /// Test the property 'Date' + /// + [Fact] + public void DateTest() + { + // TODO unit test for the property 'Date' + } + + /// + /// Test the property 'Number' + /// + [Fact] + public void NumberTest() + { + // TODO unit test for the property 'Number' + } + + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + + /// + /// Test the property 'Binary' + /// + [Fact] + public void BinaryTest() + { + // TODO unit test for the property 'Binary' + } + + /// + /// Test the property 'DateTime' + /// + [Fact] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + + /// + /// Test the property 'Decimal' + /// + [Fact] + public void DecimalTest() + { + // TODO unit test for the property 'Decimal' + } + + /// + /// Test the property 'Double' + /// + [Fact] + public void DoubleTest() + { + // TODO unit test for the property 'Double' + } + + /// + /// Test the property 'Float' + /// + [Fact] + public void FloatTest() + { + // TODO unit test for the property 'Float' + } + + /// + /// Test the property 'Int32' + /// + [Fact] + public void Int32Test() + { + // TODO unit test for the property 'Int32' + } + + /// + /// Test the property 'Int64' + /// + [Fact] + public void Int64Test() + { + // TODO unit test for the property 'Int64' + } + + /// + /// Test the property 'Integer' + /// + [Fact] + public void IntegerTest() + { + // TODO unit test for the property 'Integer' + } + + /// + /// Test the property 'PatternWithBackslash' + /// + [Fact] + public void PatternWithBackslashTest() + { + // TODO unit test for the property 'PatternWithBackslash' + } + + /// + /// Test the property 'PatternWithDigits' + /// + [Fact] + public void PatternWithDigitsTest() + { + // TODO unit test for the property 'PatternWithDigits' + } + + /// + /// Test the property 'PatternWithDigitsAndDelimiter' + /// + [Fact] + public void PatternWithDigitsAndDelimiterTest() + { + // TODO unit test for the property 'PatternWithDigitsAndDelimiter' + } + + /// + /// Test the property 'String' + /// + [Fact] + public void StringTest() + { + // TODO unit test for the property 'String' + } + + /// + /// Test the property 'UnsignedInteger' + /// + [Fact] + public void UnsignedIntegerTest() + { + // TODO unit test for the property 'UnsignedInteger' + } + + /// + /// Test the property 'UnsignedLong' + /// + [Fact] + public void UnsignedLongTest() + { + // TODO unit test for the property 'UnsignedLong' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs new file mode 100644 index 000000000000..a33c55ae4875 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitReqTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing FruitReq + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitReqTests : IDisposable + { + // TODO uncomment below to declare an instance variable for FruitReq + //private FruitReq instance; + + public FruitReqTests() + { + // TODO uncomment below to create an instance of FruitReq + //instance = new FruitReq(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of FruitReq + /// + [Fact] + public void FruitReqInstanceTest() + { + // TODO uncomment below to test "IsType" FruitReq + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitTests.cs new file mode 100644 index 000000000000..46448efc62f4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/FruitTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Fruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class FruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Fruit + //private Fruit instance; + + public FruitTests() + { + // TODO uncomment below to create an instance of Fruit + //instance = new Fruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Fruit + /// + [Fact] + public void FruitInstanceTest() + { + // TODO uncomment below to test "IsType" Fruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs new file mode 100644 index 000000000000..7e79cd067925 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GmFruitTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing GmFruit + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class GmFruitTests : IDisposable + { + // TODO uncomment below to declare an instance variable for GmFruit + //private GmFruit instance; + + public GmFruitTests() + { + // TODO uncomment below to create an instance of GmFruit + //instance = new GmFruit(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of GmFruit + /// + [Fact] + public void GmFruitInstanceTest() + { + // TODO uncomment below to test "IsType" GmFruit + //Assert.IsType(instance); + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs new file mode 100644 index 000000000000..5f0e8672ed5f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/GrandparentAnimalTests.cs @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing GrandparentAnimal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class GrandparentAnimalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for GrandparentAnimal + //private GrandparentAnimal instance; + + public GrandparentAnimalTests() + { + // TODO uncomment below to create an instance of GrandparentAnimal + //instance = new GrandparentAnimal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of GrandparentAnimal + /// + [Fact] + public void GrandparentAnimalInstanceTest() + { + // TODO uncomment below to test "IsType" GrandparentAnimal + //Assert.IsType(instance); + } + + /// + /// Test deserialize a ChildCat from type ParentPet + /// + [Fact] + public void ChildCatDeserializeFromParentPetTest() + { + // TODO uncomment below to test deserialize a ChildCat from type ParentPet + //Assert.IsType(JsonConvert.DeserializeObject(new ChildCat().ToJson())); + } + + /// + /// Test deserialize a ParentPet from type GrandparentAnimal + /// + [Fact] + public void ParentPetDeserializeFromGrandparentAnimalTest() + { + // TODO uncomment below to test deserialize a ParentPet from type GrandparentAnimal + //Assert.IsType(JsonConvert.DeserializeObject(new ParentPet().ToJson())); + } + + /// + /// Test the property 'PetType' + /// + [Fact] + public void PetTypeTest() + { + // TODO unit test for the property 'PetType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs new file mode 100644 index 000000000000..134a7d515ebb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HasOnlyReadOnlyTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing HasOnlyReadOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class HasOnlyReadOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for HasOnlyReadOnly + //private HasOnlyReadOnly instance; + + public HasOnlyReadOnlyTests() + { + // TODO uncomment below to create an instance of HasOnlyReadOnly + //instance = new HasOnlyReadOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of HasOnlyReadOnly + /// + [Fact] + public void HasOnlyReadOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" HasOnlyReadOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + + /// + /// Test the property 'Foo' + /// + [Fact] + public void FooTest() + { + // TODO unit test for the property 'Foo' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs new file mode 100644 index 000000000000..18bb8672e980 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/HealthCheckResultTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing HealthCheckResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class HealthCheckResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for HealthCheckResult + //private HealthCheckResult instance; + + public HealthCheckResultTests() + { + // TODO uncomment below to create an instance of HealthCheckResult + //instance = new HealthCheckResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of HealthCheckResult + /// + [Fact] + public void HealthCheckResultInstanceTest() + { + // TODO uncomment below to test "IsType" HealthCheckResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'NullableMessage' + /// + [Fact] + public void NullableMessageTest() + { + // TODO unit test for the property 'NullableMessage' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs new file mode 100644 index 000000000000..464750233cd2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/IsoscelesTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing IsoscelesTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class IsoscelesTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for IsoscelesTriangle + //private IsoscelesTriangle instance; + + public IsoscelesTriangleTests() + { + // TODO uncomment below to create an instance of IsoscelesTriangle + //instance = new IsoscelesTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of IsoscelesTriangle + /// + [Fact] + public void IsoscelesTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" IsoscelesTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ListTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ListTests.cs new file mode 100644 index 000000000000..d95303d97517 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ListTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing List + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ListTests : IDisposable + { + // TODO uncomment below to declare an instance variable for List + //private List instance; + + public ListTests() + { + // TODO uncomment below to create an instance of List + //instance = new List(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of List + /// + [Fact] + public void ListInstanceTest() + { + // TODO uncomment below to test "IsType" List + //Assert.IsType(instance); + } + + /// + /// Test the property 'Var123List' + /// + [Fact] + public void Var123ListTest() + { + // TODO unit test for the property 'Var123List' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs new file mode 100644 index 000000000000..31d21de5b60c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/LiteralStringClassTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing LiteralStringClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class LiteralStringClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for LiteralStringClass + //private LiteralStringClass instance; + + public LiteralStringClassTests() + { + // TODO uncomment below to create an instance of LiteralStringClass + //instance = new LiteralStringClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of LiteralStringClass + /// + [Fact] + public void LiteralStringClassInstanceTest() + { + // TODO uncomment below to test "IsType" LiteralStringClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'EscapedLiteralString' + /// + [Fact] + public void EscapedLiteralStringTest() + { + // TODO unit test for the property 'EscapedLiteralString' + } + + /// + /// Test the property 'UnescapedLiteralString' + /// + [Fact] + public void UnescapedLiteralStringTest() + { + // TODO unit test for the property 'UnescapedLiteralString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MammalTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MammalTests.cs new file mode 100644 index 000000000000..64bd9e890343 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MammalTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Mammal + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MammalTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Mammal + //private Mammal instance; + + public MammalTests() + { + // TODO uncomment below to create an instance of Mammal + //instance = new Mammal(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Mammal + /// + [Fact] + public void MammalInstanceTest() + { + // TODO uncomment below to test "IsType" Mammal + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MapTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MapTestTests.cs new file mode 100644 index 000000000000..2dc6d8d8e04b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MapTestTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MapTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MapTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MapTest + //private MapTest instance; + + public MapTestTests() + { + // TODO uncomment below to create an instance of MapTest + //instance = new MapTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MapTest + /// + [Fact] + public void MapTestInstanceTest() + { + // TODO uncomment below to test "IsType" MapTest + //Assert.IsType(instance); + } + + /// + /// Test the property 'DirectMap' + /// + [Fact] + public void DirectMapTest() + { + // TODO unit test for the property 'DirectMap' + } + + /// + /// Test the property 'IndirectMap' + /// + [Fact] + public void IndirectMapTest() + { + // TODO unit test for the property 'IndirectMap' + } + + /// + /// Test the property 'MapMapOfString' + /// + [Fact] + public void MapMapOfStringTest() + { + // TODO unit test for the property 'MapMapOfString' + } + + /// + /// Test the property 'MapOfEnumString' + /// + [Fact] + public void MapOfEnumStringTest() + { + // TODO unit test for the property 'MapOfEnumString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixLogTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixLogTests.cs new file mode 100644 index 000000000000..3f108758fd2e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixLogTests.cs @@ -0,0 +1,344 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixLog + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixLogTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixLog + //private MixLog instance; + + public MixLogTests() + { + // TODO uncomment below to create an instance of MixLog + //instance = new MixLog(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixLog + /// + [Fact] + public void MixLogInstanceTest() + { + // TODO uncomment below to test "IsType" MixLog + //Assert.IsType(instance); + } + + /// + /// Test the property 'Description' + /// + [Fact] + public void DescriptionTest() + { + // TODO unit test for the property 'Description' + } + + /// + /// Test the property 'FormulaVersionDate' + /// + [Fact] + public void FormulaVersionDateTest() + { + // TODO unit test for the property 'FormulaVersionDate' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'MixDate' + /// + [Fact] + public void MixDateTest() + { + // TODO unit test for the property 'MixDate' + } + + /// + /// Test the property 'TotalOverPoors' + /// + [Fact] + public void TotalOverPoorsTest() + { + // TODO unit test for the property 'TotalOverPoors' + } + + /// + /// Test the property 'TotalRecalculations' + /// + [Fact] + public void TotalRecalculationsTest() + { + // TODO unit test for the property 'TotalRecalculations' + } + + /// + /// Test the property 'TotalSkips' + /// + [Fact] + public void TotalSkipsTest() + { + // TODO unit test for the property 'TotalSkips' + } + + /// + /// Test the property 'TotalUnderPours' + /// + [Fact] + public void TotalUnderPoursTest() + { + // TODO unit test for the property 'TotalUnderPours' + } + + /// + /// Test the property 'BatchNumber' + /// + [Fact] + public void BatchNumberTest() + { + // TODO unit test for the property 'BatchNumber' + } + + /// + /// Test the property 'BrandCode' + /// + [Fact] + public void BrandCodeTest() + { + // TODO unit test for the property 'BrandCode' + } + + /// + /// Test the property 'BrandId' + /// + [Fact] + public void BrandIdTest() + { + // TODO unit test for the property 'BrandId' + } + + /// + /// Test the property 'BrandName' + /// + [Fact] + public void BrandNameTest() + { + // TODO unit test for the property 'BrandName' + } + + /// + /// Test the property 'CategoryCode' + /// + [Fact] + public void CategoryCodeTest() + { + // TODO unit test for the property 'CategoryCode' + } + + /// + /// Test the property 'Color' + /// + [Fact] + public void ColorTest() + { + // TODO unit test for the property 'Color' + } + + /// + /// Test the property 'ColorDescription' + /// + [Fact] + public void ColorDescriptionTest() + { + // TODO unit test for the property 'ColorDescription' + } + + /// + /// Test the property 'Comment' + /// + [Fact] + public void CommentTest() + { + // TODO unit test for the property 'Comment' + } + + /// + /// Test the property 'CommercialProductCode' + /// + [Fact] + public void CommercialProductCodeTest() + { + // TODO unit test for the property 'CommercialProductCode' + } + + /// + /// Test the property 'Country' + /// + [Fact] + public void CountryTest() + { + // TODO unit test for the property 'Country' + } + + /// + /// Test the property 'CreatedBy' + /// + [Fact] + public void CreatedByTest() + { + // TODO unit test for the property 'CreatedBy' + } + + /// + /// Test the property 'CreatedByFirstName' + /// + [Fact] + public void CreatedByFirstNameTest() + { + // TODO unit test for the property 'CreatedByFirstName' + } + + /// + /// Test the property 'CreatedByLastName' + /// + [Fact] + public void CreatedByLastNameTest() + { + // TODO unit test for the property 'CreatedByLastName' + } + + /// + /// Test the property 'DeltaECalculationRepaired' + /// + [Fact] + public void DeltaECalculationRepairedTest() + { + // TODO unit test for the property 'DeltaECalculationRepaired' + } + + /// + /// Test the property 'DeltaECalculationSprayout' + /// + [Fact] + public void DeltaECalculationSprayoutTest() + { + // TODO unit test for the property 'DeltaECalculationSprayout' + } + + /// + /// Test the property 'OwnColorVariantNumber' + /// + [Fact] + public void OwnColorVariantNumberTest() + { + // TODO unit test for the property 'OwnColorVariantNumber' + } + + /// + /// Test the property 'PrimerProductId' + /// + [Fact] + public void PrimerProductIdTest() + { + // TODO unit test for the property 'PrimerProductId' + } + + /// + /// Test the property 'ProductId' + /// + [Fact] + public void ProductIdTest() + { + // TODO unit test for the property 'ProductId' + } + + /// + /// Test the property 'ProductLineCode' + /// + [Fact] + public void ProductLineCodeTest() + { + // TODO unit test for the property 'ProductLineCode' + } + + /// + /// Test the property 'ProductName' + /// + [Fact] + public void ProductNameTest() + { + // TODO unit test for the property 'ProductName' + } + + /// + /// Test the property 'SelectedVersionIndex' + /// + [Fact] + public void SelectedVersionIndexTest() + { + // TODO unit test for the property 'SelectedVersionIndex' + } + + /// + /// Test the property 'ShopId' + /// + [Fact] + public void ShopIdTest() + { + // TODO unit test for the property 'ShopId' + } + + /// + /// Test the property 'SomeCode' + /// + [Fact] + public void SomeCodeTest() + { + // TODO unit test for the property 'SomeCode' + } + + /// + /// Test the property 'TotalPrice' + /// + [Fact] + public void TotalPriceTest() + { + // TODO unit test for the property 'TotalPrice' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs new file mode 100644 index 000000000000..d3689c15f401 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedPropertiesAndAdditionalPropertiesClassTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedPropertiesAndAdditionalPropertiesClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedPropertiesAndAdditionalPropertiesClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedPropertiesAndAdditionalPropertiesClass + //private MixedPropertiesAndAdditionalPropertiesClass instance; + + public MixedPropertiesAndAdditionalPropertiesClassTests() + { + // TODO uncomment below to create an instance of MixedPropertiesAndAdditionalPropertiesClass + //instance = new MixedPropertiesAndAdditionalPropertiesClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedPropertiesAndAdditionalPropertiesClass + /// + [Fact] + public void MixedPropertiesAndAdditionalPropertiesClassInstanceTest() + { + // TODO uncomment below to test "IsType" MixedPropertiesAndAdditionalPropertiesClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'DateTime' + /// + [Fact] + public void DateTimeTest() + { + // TODO unit test for the property 'DateTime' + } + + /// + /// Test the property 'Map' + /// + [Fact] + public void MapTest() + { + // TODO unit test for the property 'Map' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'UuidWithPattern' + /// + [Fact] + public void UuidWithPatternTest() + { + // TODO unit test for the property 'UuidWithPattern' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs new file mode 100644 index 000000000000..3b5e94c5f8f3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/Model200ResponseTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Model200Response + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class Model200ResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Model200Response + //private Model200Response instance; + + public Model200ResponseTests() + { + // TODO uncomment below to create an instance of Model200Response + //instance = new Model200Response(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Model200Response + /// + [Fact] + public void Model200ResponseInstanceTest() + { + // TODO uncomment below to test "IsType" Model200Response + //Assert.IsType(instance); + } + + /// + /// Test the property 'Class' + /// + [Fact] + public void ClassTest() + { + // TODO unit test for the property 'Class' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs new file mode 100644 index 000000000000..5a986cfdc6c2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ModelClientTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ModelClient + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ModelClientTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ModelClient + //private ModelClient instance; + + public ModelClientTests() + { + // TODO uncomment below to create an instance of ModelClient + //instance = new ModelClient(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ModelClient + /// + [Fact] + public void ModelClientInstanceTest() + { + // TODO uncomment below to test "IsType" ModelClient + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarClient' + /// + [Fact] + public void VarClientTest() + { + // TODO unit test for the property 'VarClient' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NameTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NameTests.cs new file mode 100644 index 000000000000..3aac92ae4683 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NameTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Name + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NameTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Name + //private Name instance; + + public NameTests() + { + // TODO uncomment below to create an instance of Name + //instance = new Name(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Name + /// + [Fact] + public void NameInstanceTest() + { + // TODO uncomment below to test "IsType" Name + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarName' + /// + [Fact] + public void VarNameTest() + { + // TODO unit test for the property 'VarName' + } + + /// + /// Test the property 'Property' + /// + [Fact] + public void PropertyTest() + { + // TODO unit test for the property 'Property' + } + + /// + /// Test the property 'SnakeCase' + /// + [Fact] + public void SnakeCaseTest() + { + // TODO unit test for the property 'SnakeCase' + } + + /// + /// Test the property 'Var123Number' + /// + [Fact] + public void Var123NumberTest() + { + // TODO unit test for the property 'Var123Number' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs new file mode 100644 index 000000000000..dd3b74e33061 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NotificationtestGetElementsV1ResponseMPayloadTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NotificationtestGetElementsV1ResponseMPayload + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NotificationtestGetElementsV1ResponseMPayloadTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NotificationtestGetElementsV1ResponseMPayload + //private NotificationtestGetElementsV1ResponseMPayload instance; + + public NotificationtestGetElementsV1ResponseMPayloadTests() + { + // TODO uncomment below to create an instance of NotificationtestGetElementsV1ResponseMPayload + //instance = new NotificationtestGetElementsV1ResponseMPayload(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NotificationtestGetElementsV1ResponseMPayload + /// + [Fact] + public void NotificationtestGetElementsV1ResponseMPayloadInstanceTest() + { + // TODO uncomment below to test "IsType" NotificationtestGetElementsV1ResponseMPayload + //Assert.IsType(instance); + } + + /// + /// Test the property 'AObjVariableobject' + /// + [Fact] + public void AObjVariableobjectTest() + { + // TODO unit test for the property 'AObjVariableobject' + } + + /// + /// Test the property 'PkiNotificationtestID' + /// + [Fact] + public void PkiNotificationtestIDTest() + { + // TODO unit test for the property 'PkiNotificationtestID' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs new file mode 100644 index 000000000000..1e19aa6b8231 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableClassTests.cs @@ -0,0 +1,164 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableClass + //private NullableClass instance; + + public NullableClassTests() + { + // TODO uncomment below to create an instance of NullableClass + //instance = new NullableClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableClass + /// + [Fact] + public void NullableClassInstanceTest() + { + // TODO uncomment below to test "IsType" NullableClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'ArrayAndItemsNullableProp' + /// + [Fact] + public void ArrayAndItemsNullablePropTest() + { + // TODO unit test for the property 'ArrayAndItemsNullableProp' + } + + /// + /// Test the property 'ArrayItemsNullable' + /// + [Fact] + public void ArrayItemsNullableTest() + { + // TODO unit test for the property 'ArrayItemsNullable' + } + + /// + /// Test the property 'ArrayNullableProp' + /// + [Fact] + public void ArrayNullablePropTest() + { + // TODO unit test for the property 'ArrayNullableProp' + } + + /// + /// Test the property 'BooleanProp' + /// + [Fact] + public void BooleanPropTest() + { + // TODO unit test for the property 'BooleanProp' + } + + /// + /// Test the property 'DateProp' + /// + [Fact] + public void DatePropTest() + { + // TODO unit test for the property 'DateProp' + } + + /// + /// Test the property 'DatetimeProp' + /// + [Fact] + public void DatetimePropTest() + { + // TODO unit test for the property 'DatetimeProp' + } + + /// + /// Test the property 'IntegerProp' + /// + [Fact] + public void IntegerPropTest() + { + // TODO unit test for the property 'IntegerProp' + } + + /// + /// Test the property 'NumberProp' + /// + [Fact] + public void NumberPropTest() + { + // TODO unit test for the property 'NumberProp' + } + + /// + /// Test the property 'ObjectAndItemsNullableProp' + /// + [Fact] + public void ObjectAndItemsNullablePropTest() + { + // TODO unit test for the property 'ObjectAndItemsNullableProp' + } + + /// + /// Test the property 'ObjectItemsNullable' + /// + [Fact] + public void ObjectItemsNullableTest() + { + // TODO unit test for the property 'ObjectItemsNullable' + } + + /// + /// Test the property 'ObjectNullableProp' + /// + [Fact] + public void ObjectNullablePropTest() + { + // TODO unit test for the property 'ObjectNullableProp' + } + + /// + /// Test the property 'StringProp' + /// + [Fact] + public void StringPropTest() + { + // TODO unit test for the property 'StringProp' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs new file mode 100644 index 000000000000..db8c9aa09568 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableGuidClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableGuidClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableGuidClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableGuidClass + //private NullableGuidClass instance; + + public NullableGuidClassTests() + { + // TODO uncomment below to create an instance of NullableGuidClass + //instance = new NullableGuidClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableGuidClass + /// + [Fact] + public void NullableGuidClassInstanceTest() + { + // TODO uncomment below to test "IsType" NullableGuidClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs new file mode 100644 index 000000000000..e65ba44efa2e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NullableShapeTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NullableShape + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NullableShapeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NullableShape + //private NullableShape instance; + + public NullableShapeTests() + { + // TODO uncomment below to create an instance of NullableShape + //instance = new NullableShape(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NullableShape + /// + [Fact] + public void NullableShapeInstanceTest() + { + // TODO uncomment below to test "IsType" NullableShape + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs new file mode 100644 index 000000000000..2b88fb1a609e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/NumberOnlyTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NumberOnly + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NumberOnlyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NumberOnly + //private NumberOnly instance; + + public NumberOnlyTests() + { + // TODO uncomment below to create an instance of NumberOnly + //instance = new NumberOnly(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NumberOnly + /// + [Fact] + public void NumberOnlyInstanceTest() + { + // TODO uncomment below to test "IsType" NumberOnly + //Assert.IsType(instance); + } + + /// + /// Test the property 'JustNumber' + /// + [Fact] + public void JustNumberTest() + { + // TODO unit test for the property 'JustNumber' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs new file mode 100644 index 000000000000..078655aaba70 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ObjectWithDeprecatedFieldsTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ObjectWithDeprecatedFields + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ObjectWithDeprecatedFieldsTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ObjectWithDeprecatedFields + //private ObjectWithDeprecatedFields instance; + + public ObjectWithDeprecatedFieldsTests() + { + // TODO uncomment below to create an instance of ObjectWithDeprecatedFields + //instance = new ObjectWithDeprecatedFields(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ObjectWithDeprecatedFields + /// + [Fact] + public void ObjectWithDeprecatedFieldsInstanceTest() + { + // TODO uncomment below to test "IsType" ObjectWithDeprecatedFields + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bars' + /// + [Fact] + public void BarsTest() + { + // TODO unit test for the property 'Bars' + } + + /// + /// Test the property 'DeprecatedRef' + /// + [Fact] + public void DeprecatedRefTest() + { + // TODO unit test for the property 'DeprecatedRef' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs new file mode 100644 index 000000000000..8ef411a15eb6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OneOfStringTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OneOfString + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OneOfStringTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OneOfString + //private OneOfString instance; + + public OneOfStringTests() + { + // TODO uncomment below to create an instance of OneOfString + //instance = new OneOfString(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OneOfString + /// + [Fact] + public void OneOfStringInstanceTest() + { + // TODO uncomment below to test "IsType" OneOfString + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OrderTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OrderTests.cs new file mode 100644 index 000000000000..e7187bbdc92c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OrderTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Order + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OrderTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Order + //private Order instance; + + public OrderTests() + { + // TODO uncomment below to create an instance of Order + //instance = new Order(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Order + /// + [Fact] + public void OrderInstanceTest() + { + // TODO uncomment below to test "IsType" Order + //Assert.IsType(instance); + } + + /// + /// Test the property 'Complete' + /// + [Fact] + public void CompleteTest() + { + // TODO unit test for the property 'Complete' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'PetId' + /// + [Fact] + public void PetIdTest() + { + // TODO unit test for the property 'PetId' + } + + /// + /// Test the property 'Quantity' + /// + [Fact] + public void QuantityTest() + { + // TODO unit test for the property 'Quantity' + } + + /// + /// Test the property 'ShipDate' + /// + [Fact] + public void ShipDateTest() + { + // TODO unit test for the property 'ShipDate' + } + + /// + /// Test the property 'Status' + /// + [Fact] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs new file mode 100644 index 000000000000..0bb8ce5e5d9b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterCompositeTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterComposite + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterCompositeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterComposite + //private OuterComposite instance; + + public OuterCompositeTests() + { + // TODO uncomment below to create an instance of OuterComposite + //instance = new OuterComposite(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterComposite + /// + [Fact] + public void OuterCompositeInstanceTest() + { + // TODO uncomment below to test "IsType" OuterComposite + //Assert.IsType(instance); + } + + /// + /// Test the property 'MyBoolean' + /// + [Fact] + public void MyBooleanTest() + { + // TODO unit test for the property 'MyBoolean' + } + + /// + /// Test the property 'MyNumber' + /// + [Fact] + public void MyNumberTest() + { + // TODO unit test for the property 'MyNumber' + } + + /// + /// Test the property 'MyString' + /// + [Fact] + public void MyStringTest() + { + // TODO unit test for the property 'MyString' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs new file mode 100644 index 000000000000..a1d1e1527771 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumDefaultValueTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumDefaultValue + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumDefaultValueTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumDefaultValue + //private OuterEnumDefaultValue instance; + + public OuterEnumDefaultValueTests() + { + // TODO uncomment below to create an instance of OuterEnumDefaultValue + //instance = new OuterEnumDefaultValue(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumDefaultValue + /// + [Fact] + public void OuterEnumDefaultValueInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumDefaultValue + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs new file mode 100644 index 000000000000..030326d75792 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerDefaultValueTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumIntegerDefaultValue + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumIntegerDefaultValueTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumIntegerDefaultValue + //private OuterEnumIntegerDefaultValue instance; + + public OuterEnumIntegerDefaultValueTests() + { + // TODO uncomment below to create an instance of OuterEnumIntegerDefaultValue + //instance = new OuterEnumIntegerDefaultValue(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumIntegerDefaultValue + /// + [Fact] + public void OuterEnumIntegerDefaultValueInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumIntegerDefaultValue + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs new file mode 100644 index 000000000000..1f3bfe459e76 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumIntegerTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumInteger + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumIntegerTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumInteger + //private OuterEnumInteger instance; + + public OuterEnumIntegerTests() + { + // TODO uncomment below to create an instance of OuterEnumInteger + //instance = new OuterEnumInteger(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumInteger + /// + [Fact] + public void OuterEnumIntegerInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumInteger + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs new file mode 100644 index 000000000000..c4cb8eeecee8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTestTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnumTest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumTestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnumTest + //private OuterEnumTest instance; + + public OuterEnumTestTests() + { + // TODO uncomment below to create an instance of OuterEnumTest + //instance = new OuterEnumTest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnumTest + /// + [Fact] + public void OuterEnumTestInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnumTest + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs new file mode 100644 index 000000000000..2859494010b9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/OuterEnumTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing OuterEnum + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class OuterEnumTests : IDisposable + { + // TODO uncomment below to declare an instance variable for OuterEnum + //private OuterEnum instance; + + public OuterEnumTests() + { + // TODO uncomment below to create an instance of OuterEnum + //instance = new OuterEnum(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of OuterEnum + /// + [Fact] + public void OuterEnumInstanceTest() + { + // TODO uncomment below to test "IsType" OuterEnum + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs new file mode 100644 index 000000000000..b0ebddd374f9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ParentPetTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ParentPet + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ParentPetTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ParentPet + //private ParentPet instance; + + public ParentPetTests() + { + // TODO uncomment below to create an instance of ParentPet + //instance = new ParentPet(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ParentPet + /// + [Fact] + public void ParentPetInstanceTest() + { + // TODO uncomment below to test "IsType" ParentPet + //Assert.IsType(instance); + } + + /// + /// Test deserialize a ChildCat from type ParentPet + /// + [Fact] + public void ChildCatDeserializeFromParentPetTest() + { + // TODO uncomment below to test deserialize a ChildCat from type ParentPet + //Assert.IsType(JsonConvert.DeserializeObject(new ChildCat().ToJson())); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PetTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PetTests.cs new file mode 100644 index 000000000000..8485d1213ce6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PetTests.cs @@ -0,0 +1,110 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Pet + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PetTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Pet + //private Pet instance; + + public PetTests() + { + // TODO uncomment below to create an instance of Pet + //instance = new Pet(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Pet + /// + [Fact] + public void PetInstanceTest() + { + // TODO uncomment below to test "IsType" Pet + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + + /// + /// Test the property 'PhotoUrls' + /// + [Fact] + public void PhotoUrlsTest() + { + // TODO unit test for the property 'PhotoUrls' + } + + /// + /// Test the property 'Category' + /// + [Fact] + public void CategoryTest() + { + // TODO unit test for the property 'Category' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Status' + /// + [Fact] + public void StatusTest() + { + // TODO unit test for the property 'Status' + } + + /// + /// Test the property 'Tags' + /// + [Fact] + public void TagsTest() + { + // TODO unit test for the property 'Tags' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PigTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PigTests.cs new file mode 100644 index 000000000000..bd052bc705b9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PigTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Pig + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PigTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Pig + //private Pig instance; + + public PigTests() + { + // TODO uncomment below to create an instance of Pig + //instance = new Pig(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Pig + /// + [Fact] + public void PigInstanceTest() + { + // TODO uncomment below to test "IsType" Pig + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs new file mode 100644 index 000000000000..23120ba7bdfa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/PolymorphicPropertyTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing PolymorphicProperty + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class PolymorphicPropertyTests : IDisposable + { + // TODO uncomment below to declare an instance variable for PolymorphicProperty + //private PolymorphicProperty instance; + + public PolymorphicPropertyTests() + { + // TODO uncomment below to create an instance of PolymorphicProperty + //instance = new PolymorphicProperty(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of PolymorphicProperty + /// + [Fact] + public void PolymorphicPropertyInstanceTest() + { + // TODO uncomment below to test "IsType" PolymorphicProperty + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs new file mode 100644 index 000000000000..2ddd31cfcbba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing QuadrilateralInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class QuadrilateralInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for QuadrilateralInterface + //private QuadrilateralInterface instance; + + public QuadrilateralInterfaceTests() + { + // TODO uncomment below to create an instance of QuadrilateralInterface + //instance = new QuadrilateralInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of QuadrilateralInterface + /// + [Fact] + public void QuadrilateralInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" QuadrilateralInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs new file mode 100644 index 000000000000..65673847d759 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/QuadrilateralTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Quadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class QuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Quadrilateral + //private Quadrilateral instance; + + public QuadrilateralTests() + { + // TODO uncomment below to create an instance of Quadrilateral + //instance = new Quadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Quadrilateral + /// + [Fact] + public void QuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" Quadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs new file mode 100644 index 000000000000..a4c91cf44a57 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReadOnlyFirstTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ReadOnlyFirst + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ReadOnlyFirstTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ReadOnlyFirst + //private ReadOnlyFirst instance; + + public ReadOnlyFirstTests() + { + // TODO uncomment below to create an instance of ReadOnlyFirst + //instance = new ReadOnlyFirst(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ReadOnlyFirst + /// + [Fact] + public void ReadOnlyFirstInstanceTest() + { + // TODO uncomment below to test "IsType" ReadOnlyFirst + //Assert.IsType(instance); + } + + /// + /// Test the property 'Bar' + /// + [Fact] + public void BarTest() + { + // TODO unit test for the property 'Bar' + } + + /// + /// Test the property 'Baz' + /// + [Fact] + public void BazTest() + { + // TODO unit test for the property 'Baz' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs new file mode 100644 index 000000000000..d1da68281ff0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RequiredClassTests.cs @@ -0,0 +1,452 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RequiredClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RequiredClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RequiredClass + //private RequiredClass instance; + + public RequiredClassTests() + { + // TODO uncomment below to create an instance of RequiredClass + //instance = new RequiredClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RequiredClass + /// + [Fact] + public void RequiredClassInstanceTest() + { + // TODO uncomment below to test "IsType" RequiredClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'RequiredNotNullableDateProp' + /// + [Fact] + public void RequiredNotNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNotNullableDateProp' + } + + /// + /// Test the property 'RequiredNotnullableArrayOfString' + /// + [Fact] + public void RequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'RequiredNotnullableBooleanProp' + /// + [Fact] + public void RequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'RequiredNotnullableDatetimeProp' + /// + [Fact] + public void RequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNotnullableEnumInteger' + /// + [Fact] + public void RequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'RequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNotnullableEnumString' + /// + [Fact] + public void RequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNotnullableEnumString' + } + + /// + /// Test the property 'RequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNotnullableStringProp' + /// + [Fact] + public void RequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'RequiredNotnullableStringProp' + } + + /// + /// Test the property 'RequiredNotnullableUuid' + /// + [Fact] + public void RequiredNotnullableUuidTest() + { + // TODO unit test for the property 'RequiredNotnullableUuid' + } + + /// + /// Test the property 'RequiredNotnullableintegerProp' + /// + [Fact] + public void RequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'RequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNotnullableDateProp' + /// + [Fact] + public void NotRequiredNotnullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableDateProp' + } + + /// + /// Test the property 'NotRequiredNotnullableintegerProp' + /// + [Fact] + public void NotRequiredNotnullableintegerPropTest() + { + // TODO unit test for the property 'NotRequiredNotnullableintegerProp' + } + + /// + /// Test the property 'NotRequiredNullableDateProp' + /// + [Fact] + public void NotRequiredNullableDatePropTest() + { + // TODO unit test for the property 'NotRequiredNullableDateProp' + } + + /// + /// Test the property 'NotRequiredNullableIntegerProp' + /// + [Fact] + public void NotRequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'NotRequiredNullableIntegerProp' + } + + /// + /// Test the property 'NotrequiredNotnullableArrayOfString' + /// + [Fact] + public void NotrequiredNotnullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNotnullableBooleanProp' + /// + [Fact] + public void NotrequiredNotnullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNotnullableDatetimeProp' + /// + [Fact] + public void NotrequiredNotnullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumInteger' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNotnullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNotnullableEnumString' + /// + [Fact] + public void NotrequiredNotnullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNotnullableEnumString' + } + + /// + /// Test the property 'NotrequiredNotnullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNotnullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNotnullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNotnullableStringProp' + /// + [Fact] + public void NotrequiredNotnullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNotnullableStringProp' + } + + /// + /// Test the property 'NotrequiredNotnullableUuid' + /// + [Fact] + public void NotrequiredNotnullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNotnullableUuid' + } + + /// + /// Test the property 'NotrequiredNullableArrayOfString' + /// + [Fact] + public void NotrequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'NotrequiredNullableArrayOfString' + } + + /// + /// Test the property 'NotrequiredNullableBooleanProp' + /// + [Fact] + public void NotrequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'NotrequiredNullableBooleanProp' + } + + /// + /// Test the property 'NotrequiredNullableDatetimeProp' + /// + [Fact] + public void NotrequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'NotrequiredNullableDatetimeProp' + } + + /// + /// Test the property 'NotrequiredNullableEnumInteger' + /// + [Fact] + public void NotrequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumInteger' + } + + /// + /// Test the property 'NotrequiredNullableEnumIntegerOnly' + /// + [Fact] + public void NotrequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'NotrequiredNullableEnumString' + /// + [Fact] + public void NotrequiredNullableEnumStringTest() + { + // TODO unit test for the property 'NotrequiredNullableEnumString' + } + + /// + /// Test the property 'NotrequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void NotrequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'NotrequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'NotrequiredNullableStringProp' + /// + [Fact] + public void NotrequiredNullableStringPropTest() + { + // TODO unit test for the property 'NotrequiredNullableStringProp' + } + + /// + /// Test the property 'NotrequiredNullableUuid' + /// + [Fact] + public void NotrequiredNullableUuidTest() + { + // TODO unit test for the property 'NotrequiredNullableUuid' + } + + /// + /// Test the property 'RequiredNullableArrayOfString' + /// + [Fact] + public void RequiredNullableArrayOfStringTest() + { + // TODO unit test for the property 'RequiredNullableArrayOfString' + } + + /// + /// Test the property 'RequiredNullableBooleanProp' + /// + [Fact] + public void RequiredNullableBooleanPropTest() + { + // TODO unit test for the property 'RequiredNullableBooleanProp' + } + + /// + /// Test the property 'RequiredNullableDateProp' + /// + [Fact] + public void RequiredNullableDatePropTest() + { + // TODO unit test for the property 'RequiredNullableDateProp' + } + + /// + /// Test the property 'RequiredNullableDatetimeProp' + /// + [Fact] + public void RequiredNullableDatetimePropTest() + { + // TODO unit test for the property 'RequiredNullableDatetimeProp' + } + + /// + /// Test the property 'RequiredNullableEnumInteger' + /// + [Fact] + public void RequiredNullableEnumIntegerTest() + { + // TODO unit test for the property 'RequiredNullableEnumInteger' + } + + /// + /// Test the property 'RequiredNullableEnumIntegerOnly' + /// + [Fact] + public void RequiredNullableEnumIntegerOnlyTest() + { + // TODO unit test for the property 'RequiredNullableEnumIntegerOnly' + } + + /// + /// Test the property 'RequiredNullableEnumString' + /// + [Fact] + public void RequiredNullableEnumStringTest() + { + // TODO unit test for the property 'RequiredNullableEnumString' + } + + /// + /// Test the property 'RequiredNullableIntegerProp' + /// + [Fact] + public void RequiredNullableIntegerPropTest() + { + // TODO unit test for the property 'RequiredNullableIntegerProp' + } + + /// + /// Test the property 'RequiredNullableOuterEnumDefaultValue' + /// + [Fact] + public void RequiredNullableOuterEnumDefaultValueTest() + { + // TODO unit test for the property 'RequiredNullableOuterEnumDefaultValue' + } + + /// + /// Test the property 'RequiredNullableStringProp' + /// + [Fact] + public void RequiredNullableStringPropTest() + { + // TODO unit test for the property 'RequiredNullableStringProp' + } + + /// + /// Test the property 'RequiredNullableUuid' + /// + [Fact] + public void RequiredNullableUuidTest() + { + // TODO unit test for the property 'RequiredNullableUuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReturnTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReturnTests.cs new file mode 100644 index 000000000000..bbea79ed9511 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ReturnTests.cs @@ -0,0 +1,92 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Return + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ReturnTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Return + //private Return instance; + + public ReturnTests() + { + // TODO uncomment below to create an instance of Return + //instance = new Return(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Return + /// + [Fact] + public void ReturnInstanceTest() + { + // TODO uncomment below to test "IsType" Return + //Assert.IsType(instance); + } + + /// + /// Test the property 'Lock' + /// + [Fact] + public void LockTest() + { + // TODO unit test for the property 'Lock' + } + + /// + /// Test the property 'Abstract' + /// + [Fact] + public void AbstractTest() + { + // TODO unit test for the property 'Abstract' + } + + /// + /// Test the property 'VarReturn' + /// + [Fact] + public void VarReturnTest() + { + // TODO unit test for the property 'VarReturn' + } + + /// + /// Test the property 'Unsafe' + /// + [Fact] + public void UnsafeTest() + { + // TODO unit test for the property 'Unsafe' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs new file mode 100644 index 000000000000..5f21a874c4f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashRoleTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RolesReportsHashRole + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RolesReportsHashRoleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RolesReportsHashRole + //private RolesReportsHashRole instance; + + public RolesReportsHashRoleTests() + { + // TODO uncomment below to create an instance of RolesReportsHashRole + //instance = new RolesReportsHashRole(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RolesReportsHashRole + /// + [Fact] + public void RolesReportsHashRoleInstanceTest() + { + // TODO uncomment below to test "IsType" RolesReportsHashRole + //Assert.IsType(instance); + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs new file mode 100644 index 000000000000..cddb8dc6f0b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/RolesReportsHashTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing RolesReportsHash + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class RolesReportsHashTests : IDisposable + { + // TODO uncomment below to declare an instance variable for RolesReportsHash + //private RolesReportsHash instance; + + public RolesReportsHashTests() + { + // TODO uncomment below to create an instance of RolesReportsHash + //instance = new RolesReportsHash(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of RolesReportsHash + /// + [Fact] + public void RolesReportsHashInstanceTest() + { + // TODO uncomment below to test "IsType" RolesReportsHash + //Assert.IsType(instance); + } + + /// + /// Test the property 'Role' + /// + [Fact] + public void RoleTest() + { + // TODO unit test for the property 'Role' + } + + /// + /// Test the property 'RoleUuid' + /// + [Fact] + public void RoleUuidTest() + { + // TODO unit test for the property 'RoleUuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs new file mode 100644 index 000000000000..085d3e550a10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ScaleneTriangleTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ScaleneTriangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ScaleneTriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ScaleneTriangle + //private ScaleneTriangle instance; + + public ScaleneTriangleTests() + { + // TODO uncomment below to create an instance of ScaleneTriangle + //instance = new ScaleneTriangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ScaleneTriangle + /// + [Fact] + public void ScaleneTriangleInstanceTest() + { + // TODO uncomment below to test "IsType" ScaleneTriangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs new file mode 100644 index 000000000000..62d6d69ff72d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ShapeInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ShapeInterface + //private ShapeInterface instance; + + public ShapeInterfaceTests() + { + // TODO uncomment below to create an instance of ShapeInterface + //instance = new ShapeInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ShapeInterface + /// + [Fact] + public void ShapeInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" ShapeInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs new file mode 100644 index 000000000000..dc6970b16f15 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeOrNullTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ShapeOrNull + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeOrNullTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ShapeOrNull + //private ShapeOrNull instance; + + public ShapeOrNullTests() + { + // TODO uncomment below to create an instance of ShapeOrNull + //instance = new ShapeOrNull(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ShapeOrNull + /// + [Fact] + public void ShapeOrNullInstanceTest() + { + // TODO uncomment below to test "IsType" ShapeOrNull + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeTests.cs new file mode 100644 index 000000000000..dbdf012c5ba4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ShapeTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Shape + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ShapeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Shape + //private Shape instance; + + public ShapeTests() + { + // TODO uncomment below to create an instance of Shape + //instance = new Shape(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Shape + /// + [Fact] + public void ShapeInstanceTest() + { + // TODO uncomment below to test "IsType" Shape + //Assert.IsType(instance); + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs new file mode 100644 index 000000000000..baa6e1e9f6fd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SimpleQuadrilateralTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing SimpleQuadrilateral + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class SimpleQuadrilateralTests : IDisposable + { + // TODO uncomment below to declare an instance variable for SimpleQuadrilateral + //private SimpleQuadrilateral instance; + + public SimpleQuadrilateralTests() + { + // TODO uncomment below to create an instance of SimpleQuadrilateral + //instance = new SimpleQuadrilateral(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of SimpleQuadrilateral + /// + [Fact] + public void SimpleQuadrilateralInstanceTest() + { + // TODO uncomment below to test "IsType" SimpleQuadrilateral + //Assert.IsType(instance); + } + + /// + /// Test the property 'QuadrilateralType' + /// + [Fact] + public void QuadrilateralTypeTest() + { + // TODO unit test for the property 'QuadrilateralType' + } + + /// + /// Test the property 'ShapeType' + /// + [Fact] + public void ShapeTypeTest() + { + // TODO unit test for the property 'ShapeType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs new file mode 100644 index 000000000000..23763d9c3af0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/SpecialModelNameTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing SpecialModelName + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class SpecialModelNameTests : IDisposable + { + // TODO uncomment below to declare an instance variable for SpecialModelName + //private SpecialModelName instance; + + public SpecialModelNameTests() + { + // TODO uncomment below to create an instance of SpecialModelName + //instance = new SpecialModelName(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of SpecialModelName + /// + [Fact] + public void SpecialModelNameInstanceTest() + { + // TODO uncomment below to test "IsType" SpecialModelName + //Assert.IsType(instance); + } + + /// + /// Test the property 'VarSpecialModelName' + /// + [Fact] + public void VarSpecialModelNameTest() + { + // TODO unit test for the property 'VarSpecialModelName' + } + + /// + /// Test the property 'SpecialPropertyName' + /// + [Fact] + public void SpecialPropertyNameTest() + { + // TODO unit test for the property 'SpecialPropertyName' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TagTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TagTests.cs new file mode 100644 index 000000000000..fe7f3d82baba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TagTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Tag + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TagTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Tag + //private Tag instance; + + public TagTests() + { + // TODO uncomment below to create an instance of Tag + //instance = new Tag(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Tag + /// + [Fact] + public void TagInstanceTest() + { + // TODO uncomment below to test "IsType" Tag + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'Name' + /// + [Fact] + public void NameTest() + { + // TODO unit test for the property 'Name' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs new file mode 100644 index 000000000000..eca020ce1fae --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListObjectTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestCollectionEndingWithWordListObject + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestCollectionEndingWithWordListObjectTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestCollectionEndingWithWordListObject + //private TestCollectionEndingWithWordListObject instance; + + public TestCollectionEndingWithWordListObjectTests() + { + // TODO uncomment below to create an instance of TestCollectionEndingWithWordListObject + //instance = new TestCollectionEndingWithWordListObject(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestCollectionEndingWithWordListObject + /// + [Fact] + public void TestCollectionEndingWithWordListObjectInstanceTest() + { + // TODO uncomment below to test "IsType" TestCollectionEndingWithWordListObject + //Assert.IsType(instance); + } + + /// + /// Test the property 'TestCollectionEndingWithWordList' + /// + [Fact] + public void TestCollectionEndingWithWordListTest() + { + // TODO unit test for the property 'TestCollectionEndingWithWordList' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs new file mode 100644 index 000000000000..e3c86aefabe3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestCollectionEndingWithWordListTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestCollectionEndingWithWordList + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestCollectionEndingWithWordListTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestCollectionEndingWithWordList + //private TestCollectionEndingWithWordList instance; + + public TestCollectionEndingWithWordListTests() + { + // TODO uncomment below to create an instance of TestCollectionEndingWithWordList + //instance = new TestCollectionEndingWithWordList(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestCollectionEndingWithWordList + /// + [Fact] + public void TestCollectionEndingWithWordListInstanceTest() + { + // TODO uncomment below to test "IsType" TestCollectionEndingWithWordList + //Assert.IsType(instance); + } + + /// + /// Test the property 'Value' + /// + [Fact] + public void ValueTest() + { + // TODO unit test for the property 'Value' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs new file mode 100644 index 000000000000..23e08d8e4e9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestInlineFreeformAdditionalPropertiesRequestTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TestInlineFreeformAdditionalPropertiesRequest + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestInlineFreeformAdditionalPropertiesRequestTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestInlineFreeformAdditionalPropertiesRequest + //private TestInlineFreeformAdditionalPropertiesRequest instance; + + public TestInlineFreeformAdditionalPropertiesRequestTests() + { + // TODO uncomment below to create an instance of TestInlineFreeformAdditionalPropertiesRequest + //instance = new TestInlineFreeformAdditionalPropertiesRequest(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestInlineFreeformAdditionalPropertiesRequest + /// + [Fact] + public void TestInlineFreeformAdditionalPropertiesRequestInstanceTest() + { + // TODO uncomment below to test "IsType" TestInlineFreeformAdditionalPropertiesRequest + //Assert.IsType(instance); + } + + /// + /// Test the property 'SomeProperty' + /// + [Fact] + public void SomePropertyTest() + { + // TODO unit test for the property 'SomeProperty' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs new file mode 100644 index 000000000000..1293a2b212ed --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleInterfaceTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing TriangleInterface + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TriangleInterfaceTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TriangleInterface + //private TriangleInterface instance; + + public TriangleInterfaceTests() + { + // TODO uncomment below to create an instance of TriangleInterface + //instance = new TriangleInterface(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TriangleInterface + /// + [Fact] + public void TriangleInterfaceInstanceTest() + { + // TODO uncomment below to test "IsType" TriangleInterface + //Assert.IsType(instance); + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleTests.cs new file mode 100644 index 000000000000..4cb535223483 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TriangleTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Triangle + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TriangleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Triangle + //private Triangle instance; + + public TriangleTests() + { + // TODO uncomment below to create an instance of Triangle + //instance = new Triangle(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Triangle + /// + [Fact] + public void TriangleInstanceTest() + { + // TODO uncomment below to test "IsType" Triangle + //Assert.IsType(instance); + } + + /// + /// Test the property 'TriangleType' + /// + [Fact] + public void TriangleTypeTest() + { + // TODO unit test for the property 'TriangleType' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/UserTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/UserTests.cs new file mode 100644 index 000000000000..6415f8561f1f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/UserTests.cs @@ -0,0 +1,164 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing User + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class UserTests : IDisposable + { + // TODO uncomment below to declare an instance variable for User + //private User instance; + + public UserTests() + { + // TODO uncomment below to create an instance of User + //instance = new User(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of User + /// + [Fact] + public void UserInstanceTest() + { + // TODO uncomment below to test "IsType" User + //Assert.IsType(instance); + } + + /// + /// Test the property 'AnyTypeProp' + /// + [Fact] + public void AnyTypePropTest() + { + // TODO unit test for the property 'AnyTypeProp' + } + + /// + /// Test the property 'AnyTypePropNullable' + /// + [Fact] + public void AnyTypePropNullableTest() + { + // TODO unit test for the property 'AnyTypePropNullable' + } + + /// + /// Test the property 'Email' + /// + [Fact] + public void EmailTest() + { + // TODO unit test for the property 'Email' + } + + /// + /// Test the property 'FirstName' + /// + [Fact] + public void FirstNameTest() + { + // TODO unit test for the property 'FirstName' + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + + /// + /// Test the property 'LastName' + /// + [Fact] + public void LastNameTest() + { + // TODO unit test for the property 'LastName' + } + + /// + /// Test the property 'ObjectWithNoDeclaredProps' + /// + [Fact] + public void ObjectWithNoDeclaredPropsTest() + { + // TODO unit test for the property 'ObjectWithNoDeclaredProps' + } + + /// + /// Test the property 'ObjectWithNoDeclaredPropsNullable' + /// + [Fact] + public void ObjectWithNoDeclaredPropsNullableTest() + { + // TODO unit test for the property 'ObjectWithNoDeclaredPropsNullable' + } + + /// + /// Test the property 'Password' + /// + [Fact] + public void PasswordTest() + { + // TODO unit test for the property 'Password' + } + + /// + /// Test the property 'Phone' + /// + [Fact] + public void PhoneTest() + { + // TODO unit test for the property 'Phone' + } + + /// + /// Test the property 'UserStatus' + /// + [Fact] + public void UserStatusTest() + { + // TODO unit test for the property 'UserStatus' + } + + /// + /// Test the property 'Username' + /// + [Fact] + public void UsernameTest() + { + // TODO unit test for the property 'Username' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/WhaleTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/WhaleTests.cs new file mode 100644 index 000000000000..7d05cc5e59ab --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/WhaleTests.cs @@ -0,0 +1,83 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Whale + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class WhaleTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Whale + //private Whale instance; + + public WhaleTests() + { + // TODO uncomment below to create an instance of Whale + //instance = new Whale(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Whale + /// + [Fact] + public void WhaleInstanceTest() + { + // TODO uncomment below to test "IsType" Whale + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'HasBaleen' + /// + [Fact] + public void HasBaleenTest() + { + // TODO unit test for the property 'HasBaleen' + } + + /// + /// Test the property 'HasTeeth' + /// + [Fact] + public void HasTeethTest() + { + // TODO unit test for the property 'HasTeeth' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZebraTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZebraTests.cs new file mode 100644 index 000000000000..cd0d1c1c361c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZebraTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing Zebra + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZebraTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Zebra + //private Zebra instance; + + public ZebraTests() + { + // TODO uncomment below to create an instance of Zebra + //instance = new Zebra(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Zebra + /// + [Fact] + public void ZebraInstanceTest() + { + // TODO uncomment below to test "IsType" Zebra + //Assert.IsType(instance); + } + + /// + /// Test the property 'ClassName' + /// + [Fact] + public void ClassNameTest() + { + // TODO unit test for the property 'ClassName' + } + + /// + /// Test the property 'Type' + /// + [Fact] + public void TypeTest() + { + // TODO unit test for the property 'Type' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs new file mode 100644 index 000000000000..b432edb28c23 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumClassTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZeroBasedEnumClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZeroBasedEnumClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZeroBasedEnumClass + //private ZeroBasedEnumClass instance; + + public ZeroBasedEnumClassTests() + { + // TODO uncomment below to create an instance of ZeroBasedEnumClass + //instance = new ZeroBasedEnumClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZeroBasedEnumClass + /// + [Fact] + public void ZeroBasedEnumClassInstanceTest() + { + // TODO uncomment below to test "IsType" ZeroBasedEnumClass + //Assert.IsType(instance); + } + + /// + /// Test the property 'ZeroBasedEnum' + /// + [Fact] + public void ZeroBasedEnumTest() + { + // TODO unit test for the property 'ZeroBasedEnum' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs new file mode 100644 index 000000000000..3689a873c342 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ZeroBasedEnumTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing ZeroBasedEnum + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ZeroBasedEnumTests : IDisposable + { + // TODO uncomment below to declare an instance variable for ZeroBasedEnum + //private ZeroBasedEnum instance; + + public ZeroBasedEnumTests() + { + // TODO uncomment below to create an instance of ZeroBasedEnum + //instance = new ZeroBasedEnum(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of ZeroBasedEnum + /// + [Fact] + public void ZeroBasedEnumInstanceTest() + { + // TODO uncomment below to test "IsType" ZeroBasedEnum + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs new file mode 100644 index 000000000000..c629057faada --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -0,0 +1,402 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IAnotherFakeApi : IApi + { + /// + /// The class containing the events + /// + AnotherFakeApiEvents Events { get; } + + /// + /// To test special tags + /// + /// + /// To test special tags and operation ID starting with number + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test special tags + /// + /// + /// To test special tags and operation ID starting with number + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ICall123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class AnotherFakeApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnCall123TestSpecialTags; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCall123TestSpecialTags; + + internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse) + { + OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) + { + OnErrorCall123TestSpecialTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class AnotherFakeApi : IAnotherFakeApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public AnotherFakeApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public AnotherFakeApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = anotherFakeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatCall123TestSpecialTags(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCall123TestSpecialTags(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCall123TestSpecialTagsDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorCall123TestSpecialTags(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCall123TestSpecialTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test special tags To test special tags and operation ID starting with number + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await Call123TestSpecialTagsAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test special tags To test special tags and operation ID starting with number + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCall123TestSpecialTags(modelClient); + + FormatCall123TestSpecialTags(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/another-fake/dummy"; + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnCall123TestSpecialTags(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCall123TestSpecialTagsDefaultImplementation(e, "/another-fake/dummy", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorCall123TestSpecialTags(e); + throw; + } + } + + /// + /// The + /// + public partial class Call123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, ICall123TestSpecialTagsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public Call123TestSpecialTagsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..d58e33914732 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,1352 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task FooGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Hello + /// + /// + /// Hello + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task HelloAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Hello + /// + /// + /// Hello + /// + /// Cancellation Token to cancel the request. + /// <> + Task HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task TestAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IFooGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IDefault + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IGetCountryApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IHelloApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IRolesReportGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnFooGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFooGet; + + internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse) + { + OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFooGet(Exception exception) + { + OnErrorFooGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetCountry; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetCountry; + + internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse) + { + OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetCountry(Exception exception) + { + OnErrorGetCountry?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnHello; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorHello; + + internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse) + { + OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorHello(Exception exception) + { + OnErrorHello?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnRolesReportGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorRolesReportGet; + + internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse) + { + OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorRolesReportGet(Exception exception) + { + OnErrorRolesReportGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTest; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTest; + + internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse) + { + OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTest(Exception exception) + { + OnErrorTest?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + /// + /// Processes the server response + /// + /// + private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorFooGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorFooGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFooGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FooGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task FooGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/foo"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFooGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnFooGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFooGetDefaultImplementation(e, "/foo", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFooGet(e); + throw; + } + } + + /// + /// The + /// + public partial class FooGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFooGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FooGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + /// + /// Deserializes the response if the response is 0 Default + /// + /// + public Org.OpenAPITools.Model.FooGetDefaultResponse Default() + { + // This logic may be modified with the AsModel.mustache template + return IsDefault + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 0 Default and the deserialized response is not null + /// + /// + /// + public bool TryDefault(out Org.OpenAPITools.Model.FooGetDefaultResponse result) + { + result = null; + + try + { + result = Default(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetCountry(ref string country); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateGetCountry(string country) + { + if (country == null) + throw new ArgumentNullException(nameof(country)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country) + { + bool suppressDefaultLog = false; + AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetCountryDefaultImplementation(Exception exception, string pathFormat, string path, string country) + { + bool suppressDefaultLog = false; + OnErrorGetCountry(ref suppressDefaultLog, exception, pathFormat, path, country); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetCountry(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string country); + + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetCountryAsync(country, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateGetCountry(country); + + FormatGetCountry(ref country); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/country"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetCountryDefaultImplementation(apiResponseLocalVar, country); + + Events.ExecuteOnGetCountry(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetCountryDefaultImplementation(e, "/country", uriBuilderLocalVar.Path, country); + Events.ExecuteOnErrorGetCountry(e); + throw; + } + } + + /// + /// The + /// + public partial class GetCountryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetCountryApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetCountryApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterHello(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorHelloDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorHello(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorHello(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Hello Hello + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await HelloAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Hello Hello + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task HelloAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/hello"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions); + + AfterHelloDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnHello(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorHelloDefaultImplementation(e, "/hello", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorHello(e); + throw; + } + } + + /// + /// The + /// + public partial class HelloApiResponse : Org.OpenAPITools.Client.ApiResponse, IHelloApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public HelloApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorRolesReportGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorRolesReportGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorRolesReportGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await RolesReportGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/roles/report"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions); + + AfterRolesReportGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnRolesReportGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorRolesReportGetDefaultImplementation(e, "/roles/report", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorRolesReportGet(e); + throw; + } + } + + /// + /// The + /// + public partial class RolesReportGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRolesReportGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public RolesReportGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterTest(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorTestDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorTest(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorTest(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Retrieve an existing Notificationtest's Elements + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/test"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnTest(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestDefaultImplementation(e, "/test", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorTest(e); + throw; + } + } + + /// + /// The + /// + public partial class TestApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs new file mode 100644 index 000000000000..677a0ab31c6e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -0,0 +1,5193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IFakeApi : IApi + { + /// + /// The class containing the events + /// + FakeApiEvents Events { get; } + + /// + /// Health check endpoint + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task FakeHealthGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Health check endpoint + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterBooleanSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterBooleanSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterCompositeSerializeAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterCompositeSerializeOrDefaultAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterNumberSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterNumberSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterStringSerializeAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + Task FakeOuterStringSerializeOrDefaultAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Array of Enums + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetArrayOfEnumsAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Array of Enums + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestAdditionalPropertiesReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestAdditionalPropertiesReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithFileSchemaOrDefaultAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithQueryParamsAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task TestBodyWithQueryParamsOrDefaultAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test \"client\" model + /// + /// + /// To test \"client\" model + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Thrown when fails to make API call + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string) (optional, default to -efg) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + /// <> + Task TestEnumParametersAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test enum parameters + /// + /// + /// To test enum parameters + /// + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string) (optional, default to -efg) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + /// <> + Task TestEnumParametersOrDefaultAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint to test group parameters (optional) + /// + /// + /// Fake endpoint to test group parameters (optional) + /// + /// Thrown when fails to make API call + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestGroupParametersAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Fake endpoint to test group parameters (optional) + /// + /// + /// Fake endpoint to test group parameters (optional) + /// + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestGroupParametersOrDefaultAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineAdditionalPropertiesOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline free-form additionalProperties + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineFreeformAdditionalPropertiesAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test inline free-form additionalProperties + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestInlineFreeformAdditionalPropertiesOrDefaultAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test json serialization of form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test json serialization of form data + /// + /// + /// + /// + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + Task TestJsonFormDataOrDefaultAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// To test the collection format in query parameters + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// To test the collection format in query parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task TestQueryParameterCollectionFormatOrDefaultAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced string map + /// + /// + /// + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestStringMapReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + + /// + /// test referenced string map + /// + /// + /// + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + Task TestStringMapReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IFakeHealthGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterBooleanSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterCompositeSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterNumberSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IFakeOuterStringSerializeApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestAdditionalPropertiesReferenceApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestBodyWithFileSchemaApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestBodyWithQueryParamsApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestClientModelApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestEndpointParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface ITestEnumParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface ITestGroupParametersApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface ITestInlineAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestInlineFreeformAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestJsonFormDataApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestQueryParameterCollectionFormatApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface ITestStringMapReferenceApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class FakeApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeHealthGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeHealthGet; + + internal void ExecuteOnFakeHealthGet(FakeApi.FakeHealthGetApiResponse apiResponse) + { + OnFakeHealthGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeHealthGet(Exception exception) + { + OnErrorFakeHealthGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterBooleanSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterBooleanSerialize; + + internal void ExecuteOnFakeOuterBooleanSerialize(FakeApi.FakeOuterBooleanSerializeApiResponse apiResponse) + { + OnFakeOuterBooleanSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterBooleanSerialize(Exception exception) + { + OnErrorFakeOuterBooleanSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterCompositeSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterCompositeSerialize; + + internal void ExecuteOnFakeOuterCompositeSerialize(FakeApi.FakeOuterCompositeSerializeApiResponse apiResponse) + { + OnFakeOuterCompositeSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterCompositeSerialize(Exception exception) + { + OnErrorFakeOuterCompositeSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterNumberSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterNumberSerialize; + + internal void ExecuteOnFakeOuterNumberSerialize(FakeApi.FakeOuterNumberSerializeApiResponse apiResponse) + { + OnFakeOuterNumberSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterNumberSerialize(Exception exception) + { + OnErrorFakeOuterNumberSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFakeOuterStringSerialize; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFakeOuterStringSerialize; + + internal void ExecuteOnFakeOuterStringSerialize(FakeApi.FakeOuterStringSerializeApiResponse apiResponse) + { + OnFakeOuterStringSerialize?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFakeOuterStringSerialize(Exception exception) + { + OnErrorFakeOuterStringSerialize?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetArrayOfEnums; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetArrayOfEnums; + + internal void ExecuteOnGetArrayOfEnums(FakeApi.GetArrayOfEnumsApiResponse apiResponse) + { + OnGetArrayOfEnums?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) + { + OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestAdditionalPropertiesReference; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestAdditionalPropertiesReference; + + internal void ExecuteOnTestAdditionalPropertiesReference(FakeApi.TestAdditionalPropertiesReferenceApiResponse apiResponse) + { + OnTestAdditionalPropertiesReference?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestAdditionalPropertiesReference(Exception exception) + { + OnErrorTestAdditionalPropertiesReference?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestBodyWithFileSchema; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithFileSchema; + + internal void ExecuteOnTestBodyWithFileSchema(FakeApi.TestBodyWithFileSchemaApiResponse apiResponse) + { + OnTestBodyWithFileSchema?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestBodyWithFileSchema(Exception exception) + { + OnErrorTestBodyWithFileSchema?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestBodyWithQueryParams; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestBodyWithQueryParams; + + internal void ExecuteOnTestBodyWithQueryParams(FakeApi.TestBodyWithQueryParamsApiResponse apiResponse) + { + OnTestBodyWithQueryParams?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestBodyWithQueryParams(Exception exception) + { + OnErrorTestBodyWithQueryParams?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestClientModel; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClientModel; + + internal void ExecuteOnTestClientModel(FakeApi.TestClientModelApiResponse apiResponse) + { + OnTestClientModel?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestClientModel(Exception exception) + { + OnErrorTestClientModel?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestEndpointParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEndpointParameters; + + internal void ExecuteOnTestEndpointParameters(FakeApi.TestEndpointParametersApiResponse apiResponse) + { + OnTestEndpointParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestEndpointParameters(Exception exception) + { + OnErrorTestEndpointParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestEnumParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestEnumParameters; + + internal void ExecuteOnTestEnumParameters(FakeApi.TestEnumParametersApiResponse apiResponse) + { + OnTestEnumParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestEnumParameters(Exception exception) + { + OnErrorTestEnumParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestGroupParameters; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestGroupParameters; + + internal void ExecuteOnTestGroupParameters(FakeApi.TestGroupParametersApiResponse apiResponse) + { + OnTestGroupParameters?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestGroupParameters(Exception exception) + { + OnErrorTestGroupParameters?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestInlineAdditionalProperties; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineAdditionalProperties; + + internal void ExecuteOnTestInlineAdditionalProperties(FakeApi.TestInlineAdditionalPropertiesApiResponse apiResponse) + { + OnTestInlineAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestInlineAdditionalProperties(Exception exception) + { + OnErrorTestInlineAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestInlineFreeformAdditionalProperties; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestInlineFreeformAdditionalProperties; + + internal void ExecuteOnTestInlineFreeformAdditionalProperties(FakeApi.TestInlineFreeformAdditionalPropertiesApiResponse apiResponse) + { + OnTestInlineFreeformAdditionalProperties?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestInlineFreeformAdditionalProperties(Exception exception) + { + OnErrorTestInlineFreeformAdditionalProperties?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestJsonFormData; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestJsonFormData; + + internal void ExecuteOnTestJsonFormData(FakeApi.TestJsonFormDataApiResponse apiResponse) + { + OnTestJsonFormData?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestJsonFormData(Exception exception) + { + OnErrorTestJsonFormData?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestQueryParameterCollectionFormat; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestQueryParameterCollectionFormat; + + internal void ExecuteOnTestQueryParameterCollectionFormat(FakeApi.TestQueryParameterCollectionFormatApiResponse apiResponse) + { + OnTestQueryParameterCollectionFormat?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception exception) + { + OnErrorTestQueryParameterCollectionFormat?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnTestStringMapReference; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestStringMapReference; + + internal void ExecuteOnTestStringMapReference(FakeApi.TestStringMapReferenceApiResponse apiResponse) + { + OnTestStringMapReference?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestStringMapReference(Exception exception) + { + OnErrorTestStringMapReference?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class FakeApi : IFakeApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public FakeApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = fakeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + /// + /// Processes the server response + /// + /// + private void AfterFakeHealthGetDefaultImplementation(IFakeHealthGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterFakeHealthGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterFakeHealthGet(ref bool suppressDefaultLog, IFakeHealthGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorFakeHealthGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorFakeHealthGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorFakeHealthGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Health check endpoint + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeHealthGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeHealthGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Health check endpoint + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeHealthGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/health"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeHealthGetApiResponse apiResponseLocalVar = new FakeHealthGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/health", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeHealthGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnFakeHealthGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeHealthGetDefaultImplementation(e, "/fake/health", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorFakeHealthGet(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeHealthGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeHealthGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeHealthGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.HealthCheckResult Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.HealthCheckResult result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterBooleanSerialize(ref Option body); + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterBooleanSerializeDefaultImplementation(IFakeOuterBooleanSerializeApiResponse apiResponseLocalVar, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterBooleanSerialize(ref suppressDefaultLog, apiResponseLocalVar, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterBooleanSerialize(ref bool suppressDefaultLog, IFakeOuterBooleanSerializeApiResponse apiResponseLocalVar, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterBooleanSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterBooleanSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterBooleanSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); + + /// + /// Test serialization of outer boolean types + /// + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterBooleanSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterBooleanSerializeAsync(body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterBooleanSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatFakeOuterBooleanSerialize(ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/boolean"; + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterBooleanSerializeApiResponse apiResponseLocalVar = new FakeOuterBooleanSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/boolean", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterBooleanSerializeDefaultImplementation(apiResponseLocalVar, body); + + Events.ExecuteOnFakeOuterBooleanSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterBooleanSerializeDefaultImplementation(e, "/fake/outer/boolean", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterBooleanSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterBooleanSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterBooleanSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterBooleanSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public bool? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out bool? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterCompositeSerialize(Option outerComposite); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFakeOuterCompositeSerialize(Option outerComposite) + { + if (outerComposite.IsSet && outerComposite.Value == null) + throw new ArgumentNullException(nameof(outerComposite)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterCompositeSerializeDefaultImplementation(IFakeOuterCompositeSerializeApiResponse apiResponseLocalVar, Option outerComposite) + { + bool suppressDefaultLog = false; + AfterFakeOuterCompositeSerialize(ref suppressDefaultLog, apiResponseLocalVar, outerComposite); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterCompositeSerialize(ref bool suppressDefaultLog, IFakeOuterCompositeSerializeApiResponse apiResponseLocalVar, Option outerComposite); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterCompositeSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option outerComposite) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterCompositeSerialize(ref suppressDefaultLog, exception, pathFormat, path, outerComposite); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterCompositeSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option outerComposite); + + /// + /// Test serialization of object with outer number type + /// + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterCompositeSerializeOrDefaultAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterCompositeSerializeAsync(outerComposite, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterCompositeSerializeAsync(Option outerComposite = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFakeOuterCompositeSerialize(outerComposite); + + FormatFakeOuterCompositeSerialize(outerComposite); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/composite"; + + if (outerComposite.IsSet) + httpRequestMessageLocalVar.Content = (outerComposite.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(outerComposite.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterCompositeSerializeApiResponse apiResponseLocalVar = new FakeOuterCompositeSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/composite", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterCompositeSerializeDefaultImplementation(apiResponseLocalVar, outerComposite); + + Events.ExecuteOnFakeOuterCompositeSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterCompositeSerializeDefaultImplementation(e, "/fake/outer/composite", uriBuilderLocalVar.Path, outerComposite); + Events.ExecuteOnErrorFakeOuterCompositeSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterCompositeSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterCompositeSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterCompositeSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.OuterComposite Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.OuterComposite result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterNumberSerialize(ref Option body); + + /// + /// Processes the server response + /// + /// + /// + private void AfterFakeOuterNumberSerializeDefaultImplementation(IFakeOuterNumberSerializeApiResponse apiResponseLocalVar, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterNumberSerialize(ref suppressDefaultLog, apiResponseLocalVar, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFakeOuterNumberSerialize(ref bool suppressDefaultLog, IFakeOuterNumberSerializeApiResponse apiResponseLocalVar, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFakeOuterNumberSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterNumberSerialize(ref suppressDefaultLog, exception, pathFormat, path, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterNumberSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option body); + + /// + /// Test serialization of outer number types + /// + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterNumberSerializeOrDefaultAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterNumberSerializeAsync(body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterNumberSerializeAsync(Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatFakeOuterNumberSerialize(ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/number"; + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterNumberSerializeApiResponse apiResponseLocalVar = new FakeOuterNumberSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/number", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterNumberSerializeDefaultImplementation(apiResponseLocalVar, body); + + Events.ExecuteOnFakeOuterNumberSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterNumberSerializeDefaultImplementation(e, "/fake/outer/number", uriBuilderLocalVar.Path, body); + Events.ExecuteOnErrorFakeOuterNumberSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterNumberSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterNumberSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterNumberSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public decimal? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out decimal? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFakeOuterStringSerialize(ref Guid requiredStringUuid, ref Option body); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFakeOuterStringSerialize(Option body) + { + if (body.IsSet && body.Value == null) + throw new ArgumentNullException(nameof(body)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterFakeOuterStringSerializeDefaultImplementation(IFakeOuterStringSerializeApiResponse apiResponseLocalVar, Guid requiredStringUuid, Option body) + { + bool suppressDefaultLog = false; + AfterFakeOuterStringSerialize(ref suppressDefaultLog, apiResponseLocalVar, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterFakeOuterStringSerialize(ref bool suppressDefaultLog, IFakeOuterStringSerializeApiResponse apiResponseLocalVar, Guid requiredStringUuid, Option body); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorFakeOuterStringSerializeDefaultImplementation(Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body) + { + bool suppressDefaultLog = false; + OnErrorFakeOuterStringSerialize(ref suppressDefaultLog, exception, pathFormat, path, requiredStringUuid, body); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorFakeOuterStringSerialize(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Guid requiredStringUuid, Option body); + + /// + /// Test serialization of outer string types + /// + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterStringSerializeOrDefaultAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FakeOuterStringSerializeAsync(requiredStringUuid, body, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Required UUID String + /// Input string as post body (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task FakeOuterStringSerializeAsync(Guid requiredStringUuid, Option body = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFakeOuterStringSerialize(body); + + FormatFakeOuterStringSerialize(ref requiredStringUuid, ref body); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/outer/string"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["required_string_uuid"] = ClientUtils.ParameterToString(requiredStringUuid); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + if (body.IsSet) + httpRequestMessageLocalVar.Content = (body.Value as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(body.Value, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "*/*" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FakeOuterStringSerializeApiResponse apiResponseLocalVar = new FakeOuterStringSerializeApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/outer/string", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFakeOuterStringSerializeDefaultImplementation(apiResponseLocalVar, requiredStringUuid, body); + + Events.ExecuteOnFakeOuterStringSerialize(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFakeOuterStringSerializeDefaultImplementation(e, "/fake/outer/string", uriBuilderLocalVar.Path, requiredStringUuid, body); + Events.ExecuteOnErrorFakeOuterStringSerialize(e); + throw; + } + } + + /// + /// The + /// + public partial class FakeOuterStringSerializeApiResponse : Org.OpenAPITools.Client.ApiResponse, IFakeOuterStringSerializeApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FakeOuterStringSerializeApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public string Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out string result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetArrayOfEnumsDefaultImplementation(IGetArrayOfEnumsApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetArrayOfEnums(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetArrayOfEnums(ref bool suppressDefaultLog, IGetArrayOfEnumsApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetArrayOfEnumsDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetArrayOfEnums(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetArrayOfEnums(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Array of Enums + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetArrayOfEnumsAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Array of Enums + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetArrayOfEnumsAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/array-of-enums"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetArrayOfEnumsApiResponse apiResponseLocalVar = new GetArrayOfEnumsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/array-of-enums", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetArrayOfEnumsDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetArrayOfEnums(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetArrayOfEnumsDefaultImplementation(e, "/fake/array-of-enums", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetArrayOfEnums(e); + throw; + } + } + + /// + /// The + /// + public partial class GetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetArrayOfEnumsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetArrayOfEnumsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestAdditionalPropertiesReference(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestAdditionalPropertiesReferenceDefaultImplementation(ITestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestAdditionalPropertiesReference(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestAdditionalPropertiesReference(ref bool suppressDefaultLog, ITestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestAdditionalPropertiesReferenceDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestAdditionalPropertiesReference(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestAdditionalPropertiesReference(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test referenced additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAdditionalPropertiesReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestAdditionalPropertiesReferenceAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test referenced additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestAdditionalPropertiesReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestAdditionalPropertiesReference(requestBody); + + FormatTestAdditionalPropertiesReference(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/additionalProperties-reference"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestAdditionalPropertiesReferenceApiResponse apiResponseLocalVar = new TestAdditionalPropertiesReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/additionalProperties-reference", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestAdditionalPropertiesReferenceDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestAdditionalPropertiesReference(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestAdditionalPropertiesReferenceDefaultImplementation(e, "/fake/additionalProperties-reference", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestAdditionalPropertiesReference(e); + throw; + } + } + + /// + /// The + /// + public partial class TestAdditionalPropertiesReferenceApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestAdditionalPropertiesReferenceApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestAdditionalPropertiesReferenceApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) + { + if (fileSchemaTestClass == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestBodyWithFileSchemaDefaultImplementation(ITestBodyWithFileSchemaApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass) + { + bool suppressDefaultLog = false; + AfterTestBodyWithFileSchema(ref suppressDefaultLog, apiResponseLocalVar, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestBodyWithFileSchema(ref bool suppressDefaultLog, ITestBodyWithFileSchemaApiResponse apiResponseLocalVar, FileSchemaTestClass fileSchemaTestClass); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestBodyWithFileSchemaDefaultImplementation(Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass) + { + bool suppressDefaultLog = false; + OnErrorTestBodyWithFileSchema(ref suppressDefaultLog, exception, pathFormat, path, fileSchemaTestClass); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithFileSchema(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, FileSchemaTestClass fileSchemaTestClass); + + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithFileSchemaOrDefaultAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestBodyWithFileSchemaAsync(fileSchemaTestClass, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// For this test, the body for this request much reference a schema named `File`. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithFileSchemaAsync(FileSchemaTestClass fileSchemaTestClass, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestBodyWithFileSchema(fileSchemaTestClass); + + FormatTestBodyWithFileSchema(fileSchemaTestClass); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/body-with-file-schema"; + + httpRequestMessageLocalVar.Content = (fileSchemaTestClass as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(fileSchemaTestClass, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestBodyWithFileSchemaApiResponse apiResponseLocalVar = new TestBodyWithFileSchemaApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-file-schema", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestBodyWithFileSchemaDefaultImplementation(apiResponseLocalVar, fileSchemaTestClass); + + Events.ExecuteOnTestBodyWithFileSchema(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestBodyWithFileSchemaDefaultImplementation(e, "/fake/body-with-file-schema", uriBuilderLocalVar.Path, fileSchemaTestClass); + Events.ExecuteOnErrorTestBodyWithFileSchema(e); + throw; + } + } + + /// + /// The + /// + public partial class TestBodyWithFileSchemaApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestBodyWithFileSchemaApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestBodyWithFileSchemaApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestBodyWithQueryParams(User user, ref string query); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateTestBodyWithQueryParams(User user, string query) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + + if (query == null) + throw new ArgumentNullException(nameof(query)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterTestBodyWithQueryParamsDefaultImplementation(ITestBodyWithQueryParamsApiResponse apiResponseLocalVar, User user, string query) + { + bool suppressDefaultLog = false; + AfterTestBodyWithQueryParams(ref suppressDefaultLog, apiResponseLocalVar, user, query); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterTestBodyWithQueryParams(ref bool suppressDefaultLog, ITestBodyWithQueryParamsApiResponse apiResponseLocalVar, User user, string query); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorTestBodyWithQueryParamsDefaultImplementation(Exception exception, string pathFormat, string path, User user, string query) + { + bool suppressDefaultLog = false; + OnErrorTestBodyWithQueryParams(ref suppressDefaultLog, exception, pathFormat, path, user, query); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestBodyWithQueryParams(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string query); + + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithQueryParamsOrDefaultAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestBodyWithQueryParamsAsync(user, query, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task TestBodyWithQueryParamsAsync(User user, string query, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestBodyWithQueryParams(user, query); + + FormatTestBodyWithQueryParams(user, ref query); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/body-with-query-params"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["query"] = ClientUtils.ParameterToString(query); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestBodyWithQueryParamsApiResponse apiResponseLocalVar = new TestBodyWithQueryParamsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/body-with-query-params", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestBodyWithQueryParamsDefaultImplementation(apiResponseLocalVar, user, query); + + Events.ExecuteOnTestBodyWithQueryParams(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestBodyWithQueryParamsDefaultImplementation(e, "/fake/body-with-query-params", uriBuilderLocalVar.Path, user, query); + Events.ExecuteOnErrorTestBodyWithQueryParams(e); + throw; + } + } + + /// + /// The + /// + public partial class TestBodyWithQueryParamsApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestBodyWithQueryParamsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestBodyWithQueryParamsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestClientModel(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestClientModel(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestClientModelDefaultImplementation(ITestClientModelApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterTestClientModel(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestClientModel(ref bool suppressDefaultLog, ITestClientModelApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestClientModelDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorTestClientModel(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestClientModel(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test \"client\" model To test \"client\" model + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClientModelOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestClientModelAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test \"client\" model To test \"client\" model + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClientModelAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestClientModel(modelClient); + + FormatTestClientModel(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestClientModelApiResponse apiResponseLocalVar = new TestClientModelApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestClientModelDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnTestClientModel(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestClientModelDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClientModel(e); + throw; + } + } + + /// + /// The + /// + public partial class TestClientModelApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClientModelApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestClientModelApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestEndpointParameters(ref byte[] varByte, ref decimal number, ref double varDouble, ref string patternWithoutDelimiter, ref Option date, ref Option binary, ref Option varFloat, ref Option integer, ref Option int32, ref Option int64, ref Option varString, ref Option password, ref Option callback, ref Option dateTime); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + /// + /// + /// + private void ValidateTestEndpointParameters(byte[] varByte, string patternWithoutDelimiter, Option binary, Option varString, Option password, Option callback) + { + if (varByte == null) + throw new ArgumentNullException(nameof(varByte)); + + if (patternWithoutDelimiter == null) + throw new ArgumentNullException(nameof(patternWithoutDelimiter)); + + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary)); + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString)); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password)); + + if (callback.IsSet && callback.Value == null) + throw new ArgumentNullException(nameof(callback)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestEndpointParametersDefaultImplementation(ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) + { + bool suppressDefaultLog = false; + AfterTestEndpointParameters(ref suppressDefaultLog, apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEndpointParameters(ref bool suppressDefaultLog, ITestEndpointParametersApiResponse apiResponseLocalVar, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestEndpointParametersDefaultImplementation(Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime) + { + bool suppressDefaultLog = false; + OnErrorTestEndpointParameters(ref suppressDefaultLog, exception, pathFormat, path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEndpointParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date, Option binary, Option varFloat, Option integer, Option int32, Option int64, Option varString, Option password, Option callback, Option dateTime); + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEndpointParametersOrDefaultAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestEndpointParametersAsync(varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + /// + /// Thrown when fails to make API call + /// None + /// None + /// None + /// None + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional) + /// None (optional, default to "2010-02-01T10:20:10.111110+01:00") + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEndpointParametersAsync(byte[] varByte, decimal number, double varDouble, string patternWithoutDelimiter, Option date = default, Option binary = default, Option varFloat = default, Option integer = default, Option int32 = default, Option int64 = default, Option varString = default, Option password = default, Option callback = default, Option dateTime = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestEndpointParameters(varByte, patternWithoutDelimiter, binary, varString, password, callback); + + FormatTestEndpointParameters(ref varByte, ref number, ref varDouble, ref patternWithoutDelimiter, ref date, ref binary, ref varFloat, ref integer, ref int32, ref int64, ref varString, ref password, ref callback, ref dateTime); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("byte", ClientUtils.ParameterToString(varByte))); + + formParameterLocalVars.Add(new KeyValuePair("number", ClientUtils.ParameterToString(number))); + + formParameterLocalVars.Add(new KeyValuePair("double", ClientUtils.ParameterToString(varDouble))); + + formParameterLocalVars.Add(new KeyValuePair("pattern_without_delimiter", ClientUtils.ParameterToString(patternWithoutDelimiter))); + + if (date.IsSet) + formParameterLocalVars.Add(new KeyValuePair("date", ClientUtils.ParameterToString(date.Value))); + + if (binary.IsSet) + multipartContentLocalVar.Add(new StreamContent(binary.Value)); + + if (varFloat.IsSet) + formParameterLocalVars.Add(new KeyValuePair("float", ClientUtils.ParameterToString(varFloat.Value))); + + if (integer.IsSet) + formParameterLocalVars.Add(new KeyValuePair("integer", ClientUtils.ParameterToString(integer.Value))); + + if (int32.IsSet) + formParameterLocalVars.Add(new KeyValuePair("int32", ClientUtils.ParameterToString(int32.Value))); + + if (int64.IsSet) + formParameterLocalVars.Add(new KeyValuePair("int64", ClientUtils.ParameterToString(int64.Value))); + + if (varString.IsSet) + formParameterLocalVars.Add(new KeyValuePair("string", ClientUtils.ParameterToString(varString.Value))); + + if (password.IsSet) + formParameterLocalVars.Add(new KeyValuePair("password", ClientUtils.ParameterToString(password.Value))); + + if (callback.IsSet) + formParameterLocalVars.Add(new KeyValuePair("callback", ClientUtils.ParameterToString(callback.Value))); + + if (dateTime.IsSet) + formParameterLocalVars.Add(new KeyValuePair("dateTime", ClientUtils.ParameterToString(dateTime.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + BasicToken basicTokenLocalVar1 = (BasicToken) await BasicTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(basicTokenLocalVar1); + + basicTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestEndpointParametersApiResponse apiResponseLocalVar = new TestEndpointParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestEndpointParametersDefaultImplementation(apiResponseLocalVar, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + + Events.ExecuteOnTestEndpointParameters(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestEndpointParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, varByte, number, varDouble, patternWithoutDelimiter, date, binary, varFloat, integer, int32, int64, varString, password, callback, dateTime); + Events.ExecuteOnErrorTestEndpointParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestEndpointParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestEndpointParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestEndpointParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestEnumParameters(Option> enumHeaderStringArray, Option> enumQueryStringArray, ref Option enumQueryDouble, ref Option enumQueryInteger, Option> enumFormStringArray, ref Option enumHeaderString, ref Option enumQueryString, ref Option enumFormString); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + /// + /// + /// + private void ValidateTestEnumParameters(Option> enumHeaderStringArray, Option> enumQueryStringArray, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) + { + if (enumHeaderStringArray.IsSet && enumHeaderStringArray.Value == null) + throw new ArgumentNullException(nameof(enumHeaderStringArray)); + + if (enumQueryStringArray.IsSet && enumQueryStringArray.Value == null) + throw new ArgumentNullException(nameof(enumQueryStringArray)); + + if (enumFormStringArray.IsSet && enumFormStringArray.Value == null) + throw new ArgumentNullException(nameof(enumFormStringArray)); + + if (enumHeaderString.IsSet && enumHeaderString.Value == null) + throw new ArgumentNullException(nameof(enumHeaderString)); + + if (enumQueryString.IsSet && enumQueryString.Value == null) + throw new ArgumentNullException(nameof(enumQueryString)); + + if (enumFormString.IsSet && enumFormString.Value == null) + throw new ArgumentNullException(nameof(enumFormString)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestEnumParametersDefaultImplementation(ITestEnumParametersApiResponse apiResponseLocalVar, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) + { + bool suppressDefaultLog = false; + AfterTestEnumParameters(ref suppressDefaultLog, apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestEnumParameters(ref bool suppressDefaultLog, ITestEnumParametersApiResponse apiResponseLocalVar, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestEnumParametersDefaultImplementation(Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString) + { + bool suppressDefaultLog = false; + OnErrorTestEnumParameters(ref suppressDefaultLog, exception, pathFormat, path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestEnumParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Option> enumHeaderStringArray, Option> enumQueryStringArray, Option enumQueryDouble, Option enumQueryInteger, Option> enumFormStringArray, Option enumHeaderString, Option enumQueryString, Option enumFormString); + + /// + /// To test enum parameters To test enum parameters + /// + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string) (optional, default to -efg) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEnumParametersOrDefaultAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestEnumParametersAsync(enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test enum parameters To test enum parameters + /// + /// Thrown when fails to make API call + /// Header parameter enum test (string array) (optional) + /// Query parameter enum test (string array) (optional) + /// Query parameter enum test (double) (optional) + /// Query parameter enum test (double) (optional) + /// Form parameter enum test (string array) (optional, default to $) + /// Header parameter enum test (string) (optional, default to -efg) + /// Query parameter enum test (string) (optional, default to -efg) + /// Form parameter enum test (string) (optional, default to -efg) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestEnumParametersAsync(Option> enumHeaderStringArray = default, Option> enumQueryStringArray = default, Option enumQueryDouble = default, Option enumQueryInteger = default, Option> enumFormStringArray = default, Option enumHeaderString = default, Option enumQueryString = default, Option enumFormString = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestEnumParameters(enumHeaderStringArray, enumQueryStringArray, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + + FormatTestEnumParameters(enumHeaderStringArray, enumQueryStringArray, ref enumQueryDouble, ref enumQueryInteger, enumFormStringArray, ref enumHeaderString, ref enumQueryString, ref enumFormString); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + if (enumQueryStringArray.IsSet) + // here too + parseQueryStringLocalVar["enum_query_string_array"] = ClientUtils.ParameterToString(enumQueryStringArray.Value); + + if (enumQueryDouble.IsSet) + // here too + parseQueryStringLocalVar["enum_query_double"] = ClientUtils.ParameterToString(enumQueryDouble.Value); + + if (enumQueryInteger.IsSet) + // here too + parseQueryStringLocalVar["enum_query_integer"] = ClientUtils.ParameterToString(enumQueryInteger.Value); + + if (enumQueryString.IsSet) + // here too + parseQueryStringLocalVar["enum_query_string"] = ClientUtils.ParameterToString(enumQueryString.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + if (enumHeaderStringArray.IsSet) + httpRequestMessageLocalVar.Headers.Add("enum_header_string_array", ClientUtils.ParameterToString(enumHeaderStringArray.Value)); + + if (enumHeaderString.IsSet) + httpRequestMessageLocalVar.Headers.Add("enum_header_string", ClientUtils.ParameterToString(enumHeaderString.Value)); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (enumFormStringArray.IsSet) + formParameterLocalVars.Add(new KeyValuePair("enum_form_string_array", ClientUtils.ParameterToString(enumFormStringArray.Value))); + + if (enumFormString.IsSet) + formParameterLocalVars.Add(new KeyValuePair("enum_form_string", ClientUtils.ParameterToString(enumFormString.Value))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestEnumParametersApiResponse apiResponseLocalVar = new TestEnumParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestEnumParametersDefaultImplementation(apiResponseLocalVar, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + + Events.ExecuteOnTestEnumParameters(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestEnumParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, enumHeaderStringArray, enumQueryStringArray, enumQueryDouble, enumQueryInteger, enumFormStringArray, enumHeaderString, enumQueryString, enumFormString); + Events.ExecuteOnErrorTestEnumParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestEnumParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestEnumParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestEnumParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestGroupParameters(ref bool requiredBooleanGroup, ref int requiredStringGroup, ref long requiredInt64Group, ref Option booleanGroup, ref Option stringGroup, ref Option int64Group); + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestGroupParametersDefaultImplementation(ITestGroupParametersApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) + { + bool suppressDefaultLog = false; + AfterTestGroupParameters(ref suppressDefaultLog, apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestGroupParameters(ref bool suppressDefaultLog, ITestGroupParametersApiResponse apiResponseLocalVar, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestGroupParametersDefaultImplementation(Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group) + { + bool suppressDefaultLog = false; + OnErrorTestGroupParameters(ref suppressDefaultLog, exception, pathFormat, path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestGroupParameters(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup, Option stringGroup, Option int64Group); + + /// + /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) + /// + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestGroupParametersOrDefaultAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestGroupParametersAsync(requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) + /// + /// Thrown when fails to make API call + /// Required Boolean in group parameters + /// Required String in group parameters + /// Required Integer in group parameters + /// Boolean in group parameters (optional) + /// String in group parameters (optional) + /// Integer in group parameters (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestGroupParametersAsync(bool requiredBooleanGroup, int requiredStringGroup, long requiredInt64Group, Option booleanGroup = default, Option stringGroup = default, Option int64Group = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatTestGroupParameters(ref requiredBooleanGroup, ref requiredStringGroup, ref requiredInt64Group, ref booleanGroup, ref stringGroup, ref int64Group); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["required_string_group"] = ClientUtils.ParameterToString(requiredStringGroup); + parseQueryStringLocalVar["required_int64_group"] = ClientUtils.ParameterToString(requiredInt64Group); + + if (stringGroup.IsSet) + // here too + parseQueryStringLocalVar["string_group"] = ClientUtils.ParameterToString(stringGroup.Value); + + if (int64Group.IsSet) + // here too + parseQueryStringLocalVar["int64_group"] = ClientUtils.ParameterToString(int64Group.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.Headers.Add("required_boolean_group", ClientUtils.ParameterToString(requiredBooleanGroup)); + + if (booleanGroup.IsSet) + httpRequestMessageLocalVar.Headers.Add("boolean_group", ClientUtils.ParameterToString(booleanGroup.Value)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + BearerToken bearerTokenLocalVar1 = (BearerToken) await BearerTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(bearerTokenLocalVar1); + + bearerTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestGroupParametersApiResponse apiResponseLocalVar = new TestGroupParametersApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestGroupParametersDefaultImplementation(apiResponseLocalVar, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + + Events.ExecuteOnTestGroupParameters(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestGroupParametersDefaultImplementation(e, "/fake", uriBuilderLocalVar.Path, requiredBooleanGroup, requiredStringGroup, requiredInt64Group, booleanGroup, stringGroup, int64Group); + Events.ExecuteOnErrorTestGroupParameters(e); + throw; + } + } + + /// + /// The + /// + public partial class TestGroupParametersApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestGroupParametersApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestGroupParametersApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestInlineAdditionalProperties(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestInlineAdditionalProperties(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestInlineAdditionalPropertiesDefaultImplementation(ITestInlineAdditionalPropertiesApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestInlineAdditionalProperties(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestInlineAdditionalProperties(ref bool suppressDefaultLog, ITestInlineAdditionalPropertiesApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestInlineAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestInlineAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestInlineAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test inline additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineAdditionalPropertiesOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestInlineAdditionalPropertiesAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test inline additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineAdditionalPropertiesAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestInlineAdditionalProperties(requestBody); + + FormatTestInlineAdditionalProperties(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/inline-additionalProperties"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestInlineAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestInlineAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestInlineAdditionalProperties(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestInlineAdditionalPropertiesDefaultImplementation(e, "/fake/inline-additionalProperties", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestInlineAdditionalProperties(e); + throw; + } + } + + /// + /// The + /// + public partial class TestInlineAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestInlineAdditionalPropertiesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestInlineAdditionalPropertiesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestInlineFreeformAdditionalProperties(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + if (testInlineFreeformAdditionalPropertiesRequest == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(ITestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + bool suppressDefaultLog = false; + AfterTestInlineFreeformAdditionalProperties(ref suppressDefaultLog, apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestInlineFreeformAdditionalProperties(ref bool suppressDefaultLog, ITestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestInlineFreeformAdditionalPropertiesDefaultImplementation(Exception exception, string pathFormat, string path, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest) + { + bool suppressDefaultLog = false; + OnErrorTestInlineFreeformAdditionalProperties(ref suppressDefaultLog, exception, pathFormat, path, testInlineFreeformAdditionalPropertiesRequest); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestInlineFreeformAdditionalProperties(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest); + + /// + /// test inline free-form additionalProperties + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineFreeformAdditionalPropertiesOrDefaultAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestInlineFreeformAdditionalPropertiesAsync(testInlineFreeformAdditionalPropertiesRequest, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test inline free-form additionalProperties + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestInlineFreeformAdditionalPropertiesAsync(TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + + FormatTestInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/inline-freeform-additionalProperties"; + + httpRequestMessageLocalVar.Content = (testInlineFreeformAdditionalPropertiesRequest as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(testInlineFreeformAdditionalPropertiesRequest, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestInlineFreeformAdditionalPropertiesApiResponse apiResponseLocalVar = new TestInlineFreeformAdditionalPropertiesApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/inline-freeform-additionalProperties", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestInlineFreeformAdditionalPropertiesDefaultImplementation(apiResponseLocalVar, testInlineFreeformAdditionalPropertiesRequest); + + Events.ExecuteOnTestInlineFreeformAdditionalProperties(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestInlineFreeformAdditionalPropertiesDefaultImplementation(e, "/fake/inline-freeform-additionalProperties", uriBuilderLocalVar.Path, testInlineFreeformAdditionalPropertiesRequest); + Events.ExecuteOnErrorTestInlineFreeformAdditionalProperties(e); + throw; + } + } + + /// + /// The + /// + public partial class TestInlineFreeformAdditionalPropertiesApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestInlineFreeformAdditionalPropertiesApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestInlineFreeformAdditionalPropertiesApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestJsonFormData(ref string param, ref string param2); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateTestJsonFormData(string param, string param2) + { + if (param == null) + throw new ArgumentNullException(nameof(param)); + + if (param2 == null) + throw new ArgumentNullException(nameof(param2)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterTestJsonFormDataDefaultImplementation(ITestJsonFormDataApiResponse apiResponseLocalVar, string param, string param2) + { + bool suppressDefaultLog = false; + AfterTestJsonFormData(ref suppressDefaultLog, apiResponseLocalVar, param, param2); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterTestJsonFormData(ref bool suppressDefaultLog, ITestJsonFormDataApiResponse apiResponseLocalVar, string param, string param2); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorTestJsonFormDataDefaultImplementation(Exception exception, string pathFormat, string path, string param, string param2) + { + bool suppressDefaultLog = false; + OnErrorTestJsonFormData(ref suppressDefaultLog, exception, pathFormat, path, param, param2); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestJsonFormData(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string param, string param2); + + /// + /// test json serialization of form data + /// + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + public async Task TestJsonFormDataOrDefaultAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestJsonFormDataAsync(param, param2, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test json serialization of form data + /// + /// Thrown when fails to make API call + /// field1 + /// field2 + /// Cancellation Token to cancel the request. + /// <> + public async Task TestJsonFormDataAsync(string param, string param2, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestJsonFormData(param, param2); + + FormatTestJsonFormData(ref param, ref param2); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/jsonFormData"; + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); + + formParameterLocalVars.Add(new KeyValuePair("param", ClientUtils.ParameterToString(param))); + + formParameterLocalVars.Add(new KeyValuePair("param2", ClientUtils.ParameterToString(param2))); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestJsonFormDataApiResponse apiResponseLocalVar = new TestJsonFormDataApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/jsonFormData", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestJsonFormDataDefaultImplementation(apiResponseLocalVar, param, param2); + + Events.ExecuteOnTestJsonFormData(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestJsonFormDataDefaultImplementation(e, "/fake/jsonFormData", uriBuilderLocalVar.Path, param, param2); + Events.ExecuteOnErrorTestJsonFormData(e); + throw; + } + } + + /// + /// The + /// + public partial class TestJsonFormDataApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestJsonFormDataApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestJsonFormDataApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, ref string requiredNotNullable, ref string requiredNullable, ref Option notRequiredNotNullable, ref Option notRequiredNullable); + + /// + /// Validates the request parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void ValidateTestQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, Option notRequiredNotNullable) + { + if (pipe == null) + throw new ArgumentNullException(nameof(pipe)); + + if (ioutil == null) + throw new ArgumentNullException(nameof(ioutil)); + + if (http == null) + throw new ArgumentNullException(nameof(http)); + + if (url == null) + throw new ArgumentNullException(nameof(url)); + + if (context == null) + throw new ArgumentNullException(nameof(context)); + + if (requiredNotNullable == null) + throw new ArgumentNullException(nameof(requiredNotNullable)); + + if (notRequiredNotNullable.IsSet && notRequiredNotNullable.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotNullable)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void AfterTestQueryParameterCollectionFormatDefaultImplementation(ITestQueryParameterCollectionFormatApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) + { + bool suppressDefaultLog = false; + AfterTestQueryParameterCollectionFormat(ref suppressDefaultLog, apiResponseLocalVar, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void AfterTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, ITestQueryParameterCollectionFormatApiResponse apiResponseLocalVar, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void OnErrorTestQueryParameterCollectionFormatDefaultImplementation(Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable) + { + bool suppressDefaultLog = false; + OnErrorTestQueryParameterCollectionFormat(ref suppressDefaultLog, exception, pathFormat, path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorTestQueryParameterCollectionFormat(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable, Option notRequiredNotNullable, Option notRequiredNullable); + + /// + /// To test the collection format in query parameters + /// + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestQueryParameterCollectionFormatOrDefaultAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestQueryParameterCollectionFormatAsync(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test the collection format in query parameters + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// + /// + /// + /// (optional) + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task TestQueryParameterCollectionFormatAsync(List pipe, List ioutil, List http, List url, List context, string requiredNotNullable, string requiredNullable = default, Option notRequiredNotNullable = default, Option notRequiredNullable = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, requiredNotNullable, notRequiredNotNullable); + + FormatTestQueryParameterCollectionFormat(pipe, ioutil, http, url, context, ref requiredNotNullable, ref requiredNullable, ref notRequiredNotNullable, ref notRequiredNullable); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/test-query-parameters"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["pipe"] = ClientUtils.ParameterToString(pipe); + parseQueryStringLocalVar["ioutil"] = ClientUtils.ParameterToString(ioutil); + parseQueryStringLocalVar["http"] = ClientUtils.ParameterToString(http); + parseQueryStringLocalVar["url"] = ClientUtils.ParameterToString(url); + parseQueryStringLocalVar["context"] = ClientUtils.ParameterToString(context); + parseQueryStringLocalVar["requiredNotNullable"] = ClientUtils.ParameterToString(requiredNotNullable); + parseQueryStringLocalVar["requiredNullable"] = ClientUtils.ParameterToString(requiredNullable); + + if (notRequiredNotNullable.IsSet) + // here too + parseQueryStringLocalVar["notRequiredNotNullable"] = ClientUtils.ParameterToString(notRequiredNotNullable.Value); + + if (notRequiredNullable.IsSet) + // here too + parseQueryStringLocalVar["notRequiredNullable"] = ClientUtils.ParameterToString(notRequiredNullable.Value); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestQueryParameterCollectionFormatApiResponse apiResponseLocalVar = new TestQueryParameterCollectionFormatApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/test-query-parameters", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestQueryParameterCollectionFormatDefaultImplementation(apiResponseLocalVar, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + + Events.ExecuteOnTestQueryParameterCollectionFormat(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestQueryParameterCollectionFormatDefaultImplementation(e, "/fake/test-query-parameters", uriBuilderLocalVar.Path, pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); + Events.ExecuteOnErrorTestQueryParameterCollectionFormat(e); + throw; + } + } + + /// + /// The + /// + public partial class TestQueryParameterCollectionFormatApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestQueryParameterCollectionFormatApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestQueryParameterCollectionFormatApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatTestStringMapReference(Dictionary requestBody); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestStringMapReference(Dictionary requestBody) + { + if (requestBody == null) + throw new ArgumentNullException(nameof(requestBody)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestStringMapReferenceDefaultImplementation(ITestStringMapReferenceApiResponse apiResponseLocalVar, Dictionary requestBody) + { + bool suppressDefaultLog = false; + AfterTestStringMapReference(ref suppressDefaultLog, apiResponseLocalVar, requestBody); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestStringMapReference(ref bool suppressDefaultLog, ITestStringMapReferenceApiResponse apiResponseLocalVar, Dictionary requestBody); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestStringMapReferenceDefaultImplementation(Exception exception, string pathFormat, string path, Dictionary requestBody) + { + bool suppressDefaultLog = false; + OnErrorTestStringMapReference(ref suppressDefaultLog, exception, pathFormat, path, requestBody); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestStringMapReference(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Dictionary requestBody); + + /// + /// test referenced string map + /// + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestStringMapReferenceOrDefaultAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestStringMapReferenceAsync(requestBody, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// test referenced string map + /// + /// Thrown when fails to make API call + /// request body + /// Cancellation Token to cancel the request. + /// <> + public async Task TestStringMapReferenceAsync(Dictionary requestBody, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestStringMapReference(requestBody); + + FormatTestStringMapReference(requestBody); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/stringMap-reference"; + + httpRequestMessageLocalVar.Content = (requestBody as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(requestBody, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestStringMapReferenceApiResponse apiResponseLocalVar = new TestStringMapReferenceApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/stringMap-reference", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestStringMapReferenceDefaultImplementation(apiResponseLocalVar, requestBody); + + Events.ExecuteOnTestStringMapReference(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestStringMapReferenceDefaultImplementation(e, "/fake/stringMap-reference", uriBuilderLocalVar.Path, requestBody); + Events.ExecuteOnErrorTestStringMapReference(e); + throw; + } + } + + /// + /// The + /// + public partial class TestStringMapReferenceApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestStringMapReferenceApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestStringMapReferenceApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs new file mode 100644 index 000000000000..1d5bd38c5279 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -0,0 +1,415 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IFakeClassnameTags123Api : IApi + { + /// + /// The class containing the events + /// + FakeClassnameTags123ApiEvents Events { get; } + + /// + /// To test class name in snake case + /// + /// + /// To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + + /// + /// To test class name in snake case + /// + /// + /// To test class name in snake case + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ITestClassnameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class FakeClassnameTags123ApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnTestClassname; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorTestClassname; + + internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse) + { + OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorTestClassname(Exception exception) + { + OnErrorTestClassname?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public FakeClassnameTags123ApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public FakeClassnameTags123Api(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = fakeClassnameTags123ApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatTestClassname(ModelClient modelClient); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateTestClassname(ModelClient modelClient) + { + if (modelClient == null) + throw new ArgumentNullException(nameof(modelClient)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient) + { + bool suppressDefaultLog = false; + AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorTestClassnameDefaultImplementation(Exception exception, string pathFormat, string path, ModelClient modelClient) + { + bool suppressDefaultLog = false; + OnErrorTestClassname(ref suppressDefaultLog, exception, pathFormat, path, modelClient); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorTestClassname(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, ModelClient modelClient); + + /// + /// To test class name in snake case To test class name in snake case + /// + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await TestClassnameAsync(modelClient, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// To test class name in snake case To test class name in snake case + /// + /// Thrown when fails to make API call + /// client model + /// Cancellation Token to cancel the request. + /// <> + public async Task TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateTestClassname(modelClient); + + FormatTestClassname(modelClient); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake_classname_test"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + httpRequestMessageLocalVar.Content = (modelClient as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(modelClient, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + + apiKeyTokenLocalVar1.UseInQuery(httpRequestMessageLocalVar, uriBuilderLocalVar, parseQueryStringLocalVar); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("PATCH"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions); + + AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient); + + Events.ExecuteOnTestClassname(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorTestClassnameDefaultImplementation(e, "/fake_classname_test", uriBuilderLocalVar.Path, modelClient); + Events.ExecuteOnErrorTestClassname(e); + throw; + } + } + + /// + /// The + /// + public partial class TestClassnameApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClassnameApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public TestClassnameApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ModelClient Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ModelClient result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs new file mode 100644 index 000000000000..9693c8ffacd2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/PetApi.cs @@ -0,0 +1,2784 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IPetApi : IApi + { + /// + /// The class containing the events + /// + PetApiEvents Events { get; } + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task AddPetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task AddPetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task DeletePetAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + Task DeletePetOrDefaultAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter (deprecated) + /// Cancellation Token to cancel the request. + /// <> + Task FindPetsByStatusAsync(List status, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter (deprecated) + /// Cancellation Token to cancel the request. + /// <> + Task FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + [Obsolete] + Task FindPetsByTagsAsync(List tags, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + [Obsolete] + Task FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + Task GetPetByIdAsync(long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetWithFormAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UpdatePetWithFormOrDefaultAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileOrDefaultAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image (required) + /// + /// + /// + /// + /// Thrown when fails to make API call + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileWithRequiredFileAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + + /// + /// uploads an image (required) + /// + /// + /// + /// + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + Task UploadFileWithRequiredFileOrDefaultAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IAddPetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IDeletePetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IFindPetsByStatusApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IFindPetsByTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface IGetPetByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IUpdatePetApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IUpdatePetWithFormApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + bool IsMethodNotAllowed { get; } + } + + /// + /// The + /// + public interface IUploadFileApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IUploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class PetApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnAddPet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorAddPet; + + internal void ExecuteOnAddPet(PetApi.AddPetApiResponse apiResponse) + { + OnAddPet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorAddPet(Exception exception) + { + OnErrorAddPet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnDeletePet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeletePet; + + internal void ExecuteOnDeletePet(PetApi.DeletePetApiResponse apiResponse) + { + OnDeletePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeletePet(Exception exception) + { + OnErrorDeletePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFindPetsByStatus; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByStatus; + + internal void ExecuteOnFindPetsByStatus(PetApi.FindPetsByStatusApiResponse apiResponse) + { + OnFindPetsByStatus?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFindPetsByStatus(Exception exception) + { + OnErrorFindPetsByStatus?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnFindPetsByTags; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorFindPetsByTags; + + internal void ExecuteOnFindPetsByTags(PetApi.FindPetsByTagsApiResponse apiResponse) + { + OnFindPetsByTags?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorFindPetsByTags(Exception exception) + { + OnErrorFindPetsByTags?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetPetById; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetPetById; + + internal void ExecuteOnGetPetById(PetApi.GetPetByIdApiResponse apiResponse) + { + OnGetPetById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetPetById(Exception exception) + { + OnErrorGetPetById?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdatePet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePet; + + internal void ExecuteOnUpdatePet(PetApi.UpdatePetApiResponse apiResponse) + { + OnUpdatePet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdatePet(Exception exception) + { + OnErrorUpdatePet?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdatePetWithForm; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdatePetWithForm; + + internal void ExecuteOnUpdatePetWithForm(PetApi.UpdatePetWithFormApiResponse apiResponse) + { + OnUpdatePetWithForm?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdatePetWithForm(Exception exception) + { + OnErrorUpdatePetWithForm?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFile; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFile; + + internal void ExecuteOnUploadFile(PetApi.UploadFileApiResponse apiResponse) + { + OnUploadFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFile(Exception exception) + { + OnErrorUploadFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUploadFileWithRequiredFile; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUploadFileWithRequiredFile; + + internal void ExecuteOnUploadFileWithRequiredFile(PetApi.UploadFileWithRequiredFileApiResponse apiResponse) + { + OnUploadFileWithRequiredFile?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) + { + OnErrorUploadFileWithRequiredFile?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class PetApi : IPetApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public PetApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public PetApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = petApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatAddPet(Pet pet); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateAddPet(Pet pet) + { + if (pet == null) + throw new ArgumentNullException(nameof(pet)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterAddPetDefaultImplementation(IAddPetApiResponse apiResponseLocalVar, Pet pet) + { + bool suppressDefaultLog = false; + AfterAddPet(ref suppressDefaultLog, apiResponseLocalVar, pet); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterAddPet(ref bool suppressDefaultLog, IAddPetApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorAddPetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) + { + bool suppressDefaultLog = false; + OnErrorAddPet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorAddPet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task AddPetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await AddPetAsync(pet, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Add a new pet to the store + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task AddPetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateAddPet(pet); + + FormatAddPet(pet); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + Uri urlLocalVar = httpRequestMessageLocalVar.RequestUri = new Uri("http://petstore.swagger.io/v2"); + uriBuilderLocalVar.Host = urlLocalVar.Authority; + uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; + uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; + + httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + AddPetApiResponse apiResponseLocalVar = new AddPetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + + AfterAddPetDefaultImplementation(apiResponseLocalVar, pet); + + Events.ExecuteOnAddPet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorAddPetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorAddPet(e); + throw; + } + } + + /// + /// The + /// + public partial class AddPetApiResponse : Org.OpenAPITools.Client.ApiResponse, IAddPetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public AddPetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatDeletePet(ref long petId, ref Option apiKey); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeletePet(Option apiKey) + { + if (apiKey.IsSet && apiKey.Value == null) + throw new ArgumentNullException(nameof(apiKey)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterDeletePetDefaultImplementation(IDeletePetApiResponse apiResponseLocalVar, long petId, Option apiKey) + { + bool suppressDefaultLog = false; + AfterDeletePet(ref suppressDefaultLog, apiResponseLocalVar, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterDeletePet(ref bool suppressDefaultLog, IDeletePetApiResponse apiResponseLocalVar, long petId, Option apiKey); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorDeletePetDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option apiKey) + { + bool suppressDefaultLog = false; + OnErrorDeletePet(ref suppressDefaultLog, exception, pathFormat, path, petId, apiKey); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorDeletePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option apiKey); + + /// + /// Deletes a pet + /// + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task DeletePetOrDefaultAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeletePetAsync(petId, apiKey, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Deletes a pet + /// + /// Thrown when fails to make API call + /// Pet id to delete + /// (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task DeletePetAsync(long petId, Option apiKey = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeletePet(apiKey); + + FormatDeletePet(ref petId, ref apiKey); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + if (apiKey.IsSet) + httpRequestMessageLocalVar.Headers.Add("api_key", ClientUtils.ParameterToString(apiKey.Value)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeletePetApiResponse apiResponseLocalVar = new DeletePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeletePetDefaultImplementation(apiResponseLocalVar, petId, apiKey); + + Events.ExecuteOnDeletePet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeletePetDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, apiKey); + Events.ExecuteOnErrorDeletePet(e); + throw; + } + } + + /// + /// The + /// + public partial class DeletePetApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeletePetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeletePetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFindPetsByStatus(List status); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFindPetsByStatus(List status) + { + if (status == null) + throw new ArgumentNullException(nameof(status)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFindPetsByStatusDefaultImplementation(IFindPetsByStatusApiResponse apiResponseLocalVar, List status) + { + bool suppressDefaultLog = false; + AfterFindPetsByStatus(ref suppressDefaultLog, apiResponseLocalVar, status); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFindPetsByStatus(ref bool suppressDefaultLog, IFindPetsByStatusApiResponse apiResponseLocalVar, List status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFindPetsByStatusDefaultImplementation(Exception exception, string pathFormat, string path, List status) + { + bool suppressDefaultLog = false; + OnErrorFindPetsByStatus(ref suppressDefaultLog, exception, pathFormat, path, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByStatus(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List status); + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByStatusOrDefaultAsync(List status, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FindPetsByStatusAsync(status, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Finds Pets by status Multiple status values can be provided with comma separated strings + /// + /// Thrown when fails to make API call + /// Status values that need to be considered for filter + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByStatusAsync(List status, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFindPetsByStatus(status); + + FormatFindPetsByStatus(status); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/findByStatus"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["status"] = ClientUtils.ParameterToString(status); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FindPetsByStatusApiResponse apiResponseLocalVar = new FindPetsByStatusApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByStatus", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFindPetsByStatusDefaultImplementation(apiResponseLocalVar, status); + + Events.ExecuteOnFindPetsByStatus(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFindPetsByStatusDefaultImplementation(e, "/pet/findByStatus", uriBuilderLocalVar.Path, status); + Events.ExecuteOnErrorFindPetsByStatus(e); + throw; + } + } + + /// + /// The + /// + public partial class FindPetsByStatusApiResponse : Org.OpenAPITools.Client.ApiResponse, IFindPetsByStatusApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FindPetsByStatusApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatFindPetsByTags(List tags); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateFindPetsByTags(List tags) + { + if (tags == null) + throw new ArgumentNullException(nameof(tags)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterFindPetsByTagsDefaultImplementation(IFindPetsByTagsApiResponse apiResponseLocalVar, List tags) + { + bool suppressDefaultLog = false; + AfterFindPetsByTags(ref suppressDefaultLog, apiResponseLocalVar, tags); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterFindPetsByTags(ref bool suppressDefaultLog, IFindPetsByTagsApiResponse apiResponseLocalVar, List tags); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorFindPetsByTagsDefaultImplementation(Exception exception, string pathFormat, string path, List tags) + { + bool suppressDefaultLog = false; + OnErrorFindPetsByTags(ref suppressDefaultLog, exception, pathFormat, path, tags); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorFindPetsByTags(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List tags); + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByTagsOrDefaultAsync(List tags, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await FindPetsByTagsAsync(tags, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Thrown when fails to make API call + /// Tags to filter by + /// Cancellation Token to cancel the request. + /// <> + public async Task FindPetsByTagsAsync(List tags, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateFindPetsByTags(tags); + + FormatFindPetsByTags(tags); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/findByTags"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["tags"] = ClientUtils.ParameterToString(tags); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + FindPetsByTagsApiResponse apiResponseLocalVar = new FindPetsByTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/findByTags", requestedAtLocalVar, _jsonSerializerOptions); + + AfterFindPetsByTagsDefaultImplementation(apiResponseLocalVar, tags); + + Events.ExecuteOnFindPetsByTags(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorFindPetsByTagsDefaultImplementation(e, "/pet/findByTags", uriBuilderLocalVar.Path, tags); + Events.ExecuteOnErrorFindPetsByTags(e); + throw; + } + } + + /// + /// The + /// + public partial class FindPetsByTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, IFindPetsByTagsApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public FindPetsByTagsApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public List Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out List result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetPetById(ref long petId); + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetPetByIdDefaultImplementation(IGetPetByIdApiResponse apiResponseLocalVar, long petId) + { + bool suppressDefaultLog = false; + AfterGetPetById(ref suppressDefaultLog, apiResponseLocalVar, petId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetPetById(ref bool suppressDefaultLog, IGetPetByIdApiResponse apiResponseLocalVar, long petId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetPetByIdDefaultImplementation(Exception exception, string pathFormat, string path, long petId) + { + bool suppressDefaultLog = false; + OnErrorGetPetById(ref suppressDefaultLog, exception, pathFormat, path, petId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetPetById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId); + + /// + /// Find pet by ID Returns a single pet + /// + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + public async Task GetPetByIdOrDefaultAsync(long petId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetPetByIdAsync(petId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Find pet by ID Returns a single pet + /// + /// Thrown when fails to make API call + /// ID of pet to return + /// Cancellation Token to cancel the request. + /// <> + public async Task GetPetByIdAsync(long petId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatGetPetById(ref petId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + apiKeyTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar); + + ApiKeyToken apiKeyTokenLocalVar2 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key_query", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar2); + + apiKeyTokenLocalVar2.UseInQuery(httpRequestMessageLocalVar, uriBuilderLocalVar, parseQueryStringLocalVar); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetPetByIdApiResponse apiResponseLocalVar = new GetPetByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetPetByIdDefaultImplementation(apiResponseLocalVar, petId); + + Events.ExecuteOnGetPetById(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetPetByIdDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId); + Events.ExecuteOnErrorGetPetById(e); + throw; + } + } + + /// + /// The + /// + public partial class GetPetByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetPetByIdApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetPetByIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Pet Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Pet result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdatePet(Pet pet); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateUpdatePet(Pet pet) + { + if (pet == null) + throw new ArgumentNullException(nameof(pet)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterUpdatePetDefaultImplementation(IUpdatePetApiResponse apiResponseLocalVar, Pet pet) + { + bool suppressDefaultLog = false; + AfterUpdatePet(ref suppressDefaultLog, apiResponseLocalVar, pet); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterUpdatePet(ref bool suppressDefaultLog, IUpdatePetApiResponse apiResponseLocalVar, Pet pet); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorUpdatePetDefaultImplementation(Exception exception, string pathFormat, string path, Pet pet) + { + bool suppressDefaultLog = false; + OnErrorUpdatePet(ref suppressDefaultLog, exception, pathFormat, path, pet); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Pet pet); + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetOrDefaultAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdatePetAsync(pet, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Update an existing pet + /// + /// Thrown when fails to make API call + /// Pet object that needs to be added to the store + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetAsync(Pet pet, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdatePet(pet); + + FormatUpdatePet(pet); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + Uri urlLocalVar = httpRequestMessageLocalVar.RequestUri = new Uri("http://petstore.swagger.io/v2"); + uriBuilderLocalVar.Host = urlLocalVar.Authority; + uriBuilderLocalVar.Scheme = urlLocalVar.Scheme; + uriBuilderLocalVar.Path = urlLocalVar.AbsolutePath; + + httpRequestMessageLocalVar.Content = (pet as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(pet, _jsonSerializerOptions)); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + + if (httpRequestMessageLocalVar.Content != null) { + string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + } + + string[] contentTypes = new string[] { + "application/json", + "application/xml" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdatePetApiResponse apiResponseLocalVar = new UpdatePetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdatePetDefaultImplementation(apiResponseLocalVar, pet); + + Events.ExecuteOnUpdatePet(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdatePetDefaultImplementation(e, "/pet", uriBuilderLocalVar.Path, pet); + Events.ExecuteOnErrorUpdatePet(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdatePetApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdatePetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdatePetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdatePetWithForm(ref long petId, ref Option name, ref Option status); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUpdatePetWithForm(Option name, Option status) + { + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name)); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUpdatePetWithFormDefaultImplementation(IUpdatePetWithFormApiResponse apiResponseLocalVar, long petId, Option name, Option status) + { + bool suppressDefaultLog = false; + AfterUpdatePetWithForm(ref suppressDefaultLog, apiResponseLocalVar, petId, name, status); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUpdatePetWithForm(ref bool suppressDefaultLog, IUpdatePetWithFormApiResponse apiResponseLocalVar, long petId, Option name, Option status); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUpdatePetWithFormDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option name, Option status) + { + bool suppressDefaultLog = false; + OnErrorUpdatePetWithForm(ref suppressDefaultLog, exception, pathFormat, path, petId, name, status); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdatePetWithForm(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option name, Option status); + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetWithFormOrDefaultAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdatePetWithFormAsync(petId, name, status, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Updates a pet in the store with form data + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be updated + /// Updated name of the pet (optional) + /// Updated status of the pet (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdatePetWithFormAsync(long petId, Option name = default, Option status = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdatePetWithForm(name, status); + + FormatUpdatePetWithForm(ref petId, ref name, ref status); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (name.IsSet) + formParameterLocalVars.Add(new KeyValuePair("name", ClientUtils.ParameterToString(name.Value))); + + if (status.IsSet) + formParameterLocalVars.Add(new KeyValuePair("status", ClientUtils.ParameterToString(status.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdatePetWithFormApiResponse apiResponseLocalVar = new UpdatePetWithFormApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdatePetWithFormDefaultImplementation(apiResponseLocalVar, petId, name, status); + + Events.ExecuteOnUpdatePetWithForm(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdatePetWithFormDefaultImplementation(e, "/pet/{petId}", uriBuilderLocalVar.Path, petId, name, status); + Events.ExecuteOnErrorUpdatePetWithForm(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdatePetWithFormApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdatePetWithFormApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdatePetWithFormApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 405 MethodNotAllowed + /// + /// + public bool IsMethodNotAllowed => 405 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUploadFile(ref long petId, ref Option file, ref Option additionalMetadata); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUploadFile(Option file, Option additionalMetadata) + { + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file)); + + if (additionalMetadata.IsSet && additionalMetadata.Value == null) + throw new ArgumentNullException(nameof(additionalMetadata)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUploadFileDefaultImplementation(IUploadFileApiResponse apiResponseLocalVar, long petId, Option file, Option additionalMetadata) + { + bool suppressDefaultLog = false; + AfterUploadFile(ref suppressDefaultLog, apiResponseLocalVar, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUploadFile(ref bool suppressDefaultLog, IUploadFileApiResponse apiResponseLocalVar, long petId, Option file, Option additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFileDefaultImplementation(Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata) + { + bool suppressDefaultLog = false; + OnErrorUploadFile(ref suppressDefaultLog, exception, pathFormat, path, petId, file, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long petId, Option file, Option additionalMetadata); + + /// + /// uploads an image + /// + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileOrDefaultAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFileAsync(petId, file, additionalMetadata, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an image + /// + /// Thrown when fails to make API call + /// ID of pet to update + /// file to upload (optional) + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileAsync(long petId, Option file = default, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFile(file, additionalMetadata); + + FormatUploadFile(ref petId, ref file, ref additionalMetadata); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/pet/{petId}/uploadImage"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); if (file.IsSet) + multipartContentLocalVar.Add(new StreamContent(file.Value)); + + if (additionalMetadata.IsSet) + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UploadFileApiResponse apiResponseLocalVar = new UploadFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/pet/{petId}/uploadImage", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUploadFileDefaultImplementation(apiResponseLocalVar, petId, file, additionalMetadata); + + Events.ExecuteOnUploadFile(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFileDefaultImplementation(e, "/pet/{petId}/uploadImage", uriBuilderLocalVar.Path, petId, file, additionalMetadata); + Events.ExecuteOnErrorUploadFile(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFileApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFileApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFileApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUploadFileWithRequiredFile(ref System.IO.Stream requiredFile, ref long petId, ref Option additionalMetadata); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUploadFileWithRequiredFile(System.IO.Stream requiredFile, Option additionalMetadata) + { + if (requiredFile == null) + throw new ArgumentNullException(nameof(requiredFile)); + + if (additionalMetadata.IsSet && additionalMetadata.Value == null) + throw new ArgumentNullException(nameof(additionalMetadata)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + private void AfterUploadFileWithRequiredFileDefaultImplementation(IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, Option additionalMetadata) + { + bool suppressDefaultLog = false; + AfterUploadFileWithRequiredFile(ref suppressDefaultLog, apiResponseLocalVar, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + /// + partial void AfterUploadFileWithRequiredFile(ref bool suppressDefaultLog, IUploadFileWithRequiredFileApiResponse apiResponseLocalVar, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + /// + private void OnErrorUploadFileWithRequiredFileDefaultImplementation(Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata) + { + bool suppressDefaultLog = false; + OnErrorUploadFileWithRequiredFile(ref suppressDefaultLog, exception, pathFormat, path, requiredFile, petId, additionalMetadata); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUploadFileWithRequiredFile(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, System.IO.Stream requiredFile, long petId, Option additionalMetadata); + + /// + /// uploads an image (required) + /// + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileWithRequiredFileOrDefaultAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// uploads an image (required) + /// + /// Thrown when fails to make API call + /// file to upload + /// ID of pet to update + /// Additional data to pass to server (optional) + /// Cancellation Token to cancel the request. + /// <> + public async Task UploadFileWithRequiredFileAsync(System.IO.Stream requiredFile, long petId, Option additionalMetadata = default, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUploadFileWithRequiredFile(requiredFile, additionalMetadata); + + FormatUploadFileWithRequiredFile(ref requiredFile, ref petId, ref additionalMetadata); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/{petId}/uploadImageWithRequiredFile"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BpetId%7D", Uri.EscapeDataString(petId.ToString())); + + MultipartContent multipartContentLocalVar = new MultipartContent(); + + httpRequestMessageLocalVar.Content = multipartContentLocalVar; + + List> formParameterLocalVars = new List>(); + + multipartContentLocalVar.Add(new FormUrlEncodedContent(formParameterLocalVars)); multipartContentLocalVar.Add(new StreamContent(requiredFile)); + + if (additionalMetadata.IsSet) + formParameterLocalVars.Add(new KeyValuePair("additionalMetadata", ClientUtils.ParameterToString(additionalMetadata.Value))); + + List tokenBaseLocalVars = new List(); + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + OAuthToken oauthTokenLocalVar1 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(oauthTokenLocalVar1); + + oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); + + string[] contentTypes = new string[] { + "multipart/form-data" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/json", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UploadFileWithRequiredFileApiResponse apiResponseLocalVar = new UploadFileWithRequiredFileApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/{petId}/uploadImageWithRequiredFile", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUploadFileWithRequiredFileDefaultImplementation(apiResponseLocalVar, requiredFile, petId, additionalMetadata); + + Events.ExecuteOnUploadFileWithRequiredFile(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUploadFileWithRequiredFileDefaultImplementation(e, "/fake/{petId}/uploadImageWithRequiredFile", uriBuilderLocalVar.Path, requiredFile, petId, additionalMetadata); + Events.ExecuteOnErrorUploadFileWithRequiredFile(e); + throw; + } + } + + /// + /// The + /// + public partial class UploadFileWithRequiredFileApiResponse : Org.OpenAPITools.Client.ApiResponse, IUploadFileWithRequiredFileApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UploadFileWithRequiredFileApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.ApiResponse Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.ApiResponse result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs new file mode 100644 index 000000000000..4e9980c869e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/StoreApi.cs @@ -0,0 +1,1197 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IStoreApi : IApi + { + /// + /// The class containing the events + /// + StoreApiEvents Events { get; } + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + Task DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Cancellation Token to cancel the request. + /// <> + Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + Task PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface IDeleteOrderApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IGetInventoryApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk> + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetOrderByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IPlaceOrderApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class StoreApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnDeleteOrder; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteOrder; + + internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse) + { + OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeleteOrder(Exception exception) + { + OnErrorDeleteOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetInventory; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetInventory; + + internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse) + { + OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetInventory(Exception exception) + { + OnErrorGetInventory?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetOrderById; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetOrderById; + + internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse) + { + OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetOrderById(Exception exception) + { + OnErrorGetOrderById?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnPlaceOrder; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorPlaceOrder; + + internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse) + { + OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorPlaceOrder(Exception exception) + { + OnErrorPlaceOrder?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class StoreApi : IStoreApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public StoreApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public StoreApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = storeApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatDeleteOrder(ref string orderId); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeleteOrder(string orderId) + { + if (orderId == null) + throw new ArgumentNullException(nameof(orderId)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId) + { + bool suppressDefaultLog = false; + AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorDeleteOrderDefaultImplementation(Exception exception, string pathFormat, string path, string orderId) + { + bool suppressDefaultLog = false; + OnErrorDeleteOrder(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeleteOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string orderId); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeleteOrderAsync(orderId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// Thrown when fails to make API call + /// ID of the order that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeleteOrder(orderId); + + FormatDeleteOrder(ref orderId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order/{order_id}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId); + + Events.ExecuteOnDeleteOrder(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeleteOrderDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorDeleteOrder(e); + throw; + } + } + + /// + /// The + /// + public partial class DeleteOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteOrderApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeleteOrderApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetInventoryDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetInventory(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetInventory(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetInventoryAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/inventory"; + + List tokenBaseLocalVars = new List(); + ApiKeyToken apiKeyTokenLocalVar1 = (ApiKeyToken) await ApiKeyProvider.GetAsync("api_key", cancellationToken).ConfigureAwait(false); + tokenBaseLocalVars.Add(apiKeyTokenLocalVar1); + apiKeyTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetInventoryDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetInventory(apiResponseLocalVar); + + if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429) + foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars) + tokenBaseLocalVar.BeginRateLimit(); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetInventoryDefaultImplementation(e, "/store/inventory", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetInventory(e); + throw; + } + } + + /// + /// The + /// + public partial class GetInventoryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetInventoryApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetInventoryApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Dictionary Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize>(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Dictionary result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetOrderById(ref long orderId); + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId) + { + bool suppressDefaultLog = false; + AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetOrderByIdDefaultImplementation(Exception exception, string pathFormat, string path, long orderId) + { + bool suppressDefaultLog = false; + OnErrorGetOrderById(ref suppressDefaultLog, exception, pathFormat, path, orderId); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetOrderById(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, long orderId); + + /// + /// 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 + /// Cancellation Token to cancel the request. + /// <> + public async Task GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetOrderByIdAsync(orderId, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// Thrown when fails to make API call + /// ID of pet that needs to be fetched + /// Cancellation Token to cancel the request. + /// <> + public async Task GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + FormatGetOrderById(ref orderId); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order/{order_id}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Border_id%7D", Uri.EscapeDataString(orderId.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId); + + Events.ExecuteOnGetOrderById(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetOrderByIdDefaultImplementation(e, "/store/order/{order_id}", uriBuilderLocalVar.Path, orderId); + Events.ExecuteOnErrorGetOrderById(e); + throw; + } + } + + /// + /// The + /// + public partial class GetOrderByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetOrderByIdApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetOrderByIdApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Order Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Order result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatPlaceOrder(Order order); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidatePlaceOrder(Order order) + { + if (order == null) + throw new ArgumentNullException(nameof(order)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order) + { + bool suppressDefaultLog = false; + AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorPlaceOrderDefaultImplementation(Exception exception, string pathFormat, string path, Order order) + { + bool suppressDefaultLog = false; + OnErrorPlaceOrder(ref suppressDefaultLog, exception, pathFormat, path, order); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorPlaceOrder(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, Order order); + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + public async Task PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await PlaceOrderAsync(order, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Place an order for a pet + /// + /// Thrown when fails to make API call + /// order placed for purchasing the pet + /// Cancellation Token to cancel the request. + /// <> + public async Task PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidatePlaceOrder(order); + + FormatPlaceOrder(order); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/store/order"; + + httpRequestMessageLocalVar.Content = (order as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(order, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions); + + AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order); + + Events.ExecuteOnPlaceOrder(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorPlaceOrderDefaultImplementation(e, "/store/order", uriBuilderLocalVar.Path, order); + Events.ExecuteOnErrorPlaceOrder(e); + throw; + } + } + + /// + /// The + /// + public partial class PlaceOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IPlaceOrderApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public PlaceOrderApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.Order Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.Order result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs new file mode 100644 index 000000000000..721984089ad9 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/UserApi.cs @@ -0,0 +1,2223 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IUserApi : IApi + { + /// + /// The class containing the events + /// + UserApiEvents Events { get; } + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUserAsync(User user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUserOrDefaultAsync(User user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithArrayInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + Task CreateUsersWithListInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteUserAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task DeleteUserOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Get user by user name + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + Task GetUserByNameAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + Task LoginUserAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task LogoutUserAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task LogoutUserOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task UpdateUserAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + Task UpdateUserOrDefaultAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface ICreateUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface ICreateUsersWithArrayInputApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface ICreateUsersWithListInputApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IDeleteUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// The + /// + public interface IGetUserByNameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk, ICustomHttpStatusCode599 + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + + /// + /// Returns true if the response is 598 CustomHttpStatusCode598 + /// + /// + bool IsCustomHttpStatusCode598 { get; } + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 + /// + /// + bool IsCustomHttpStatusCode599 { get; } + } + + /// + /// The + /// + public interface ILoginUserApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + } + + /// + /// The + /// + public interface ILogoutUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is the default response type + /// + /// + bool IsDefault { get; } + } + + /// + /// The + /// + public interface IUpdateUserApiResponse : Org.OpenAPITools.Client.IApiResponse + { + /// + /// Returns true if the response is 400 BadRequest + /// + /// + bool IsBadRequest { get; } + + /// + /// Returns true if the response is 404 NotFound + /// + /// + bool IsNotFound { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class UserApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUser; + + internal void ExecuteOnCreateUser(UserApi.CreateUserApiResponse apiResponse) + { + OnCreateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUser(Exception exception) + { + OnErrorCreateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUsersWithArrayInput; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithArrayInput; + + internal void ExecuteOnCreateUsersWithArrayInput(UserApi.CreateUsersWithArrayInputApiResponse apiResponse) + { + OnCreateUsersWithArrayInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUsersWithArrayInput(Exception exception) + { + OnErrorCreateUsersWithArrayInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnCreateUsersWithListInput; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorCreateUsersWithListInput; + + internal void ExecuteOnCreateUsersWithListInput(UserApi.CreateUsersWithListInputApiResponse apiResponse) + { + OnCreateUsersWithListInput?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorCreateUsersWithListInput(Exception exception) + { + OnErrorCreateUsersWithListInput?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnDeleteUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorDeleteUser; + + internal void ExecuteOnDeleteUser(UserApi.DeleteUserApiResponse apiResponse) + { + OnDeleteUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorDeleteUser(Exception exception) + { + OnErrorDeleteUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetUserByName; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetUserByName; + + internal void ExecuteOnGetUserByName(UserApi.GetUserByNameApiResponse apiResponse) + { + OnGetUserByName?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetUserByName(Exception exception) + { + OnErrorGetUserByName?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnLoginUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLoginUser; + + internal void ExecuteOnLoginUser(UserApi.LoginUserApiResponse apiResponse) + { + OnLoginUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorLoginUser(Exception exception) + { + OnErrorLoginUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnLogoutUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorLogoutUser; + + internal void ExecuteOnLogoutUser(UserApi.LogoutUserApiResponse apiResponse) + { + OnLogoutUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorLogoutUser(Exception exception) + { + OnErrorLogoutUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnUpdateUser; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorUpdateUser; + + internal void ExecuteOnUpdateUser(UserApi.UpdateUserApiResponse apiResponse) + { + OnUpdateUser?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorUpdateUser(Exception exception) + { + OnErrorUpdateUser?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class UserApi : IUserApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public UserApiEvents Events { get; } + + /// + /// A token provider of type + /// + public TokenProvider ApiKeyProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BearerTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider BasicTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider HttpSignatureTokenProvider { get; } + + /// + /// A token provider of type + /// + public TokenProvider OauthTokenProvider { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public UserApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents, + TokenProvider apiKeyProvider, + TokenProvider bearerTokenProvider, + TokenProvider basicTokenProvider, + TokenProvider httpSignatureTokenProvider, + TokenProvider oauthTokenProvider) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = userApiEvents; + ApiKeyProvider = apiKeyProvider; + BearerTokenProvider = bearerTokenProvider; + BasicTokenProvider = basicTokenProvider; + HttpSignatureTokenProvider = httpSignatureTokenProvider; + OauthTokenProvider = oauthTokenProvider; + } + + partial void FormatCreateUser(User user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUser(User user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUserDefaultImplementation(ICreateUserApiResponse apiResponseLocalVar, User user) + { + bool suppressDefaultLog = false; + AfterCreateUser(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUser(ref bool suppressDefaultLog, ICreateUserApiResponse apiResponseLocalVar, User user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user) + { + bool suppressDefaultLog = false; + OnErrorCreateUser(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user); + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUserOrDefaultAsync(User user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUserAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Created user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUserAsync(User user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUser(user); + + FormatCreateUser(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUserApiResponse apiResponseLocalVar = new CreateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUserDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUserDefaultImplementation(e, "/user", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUser(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatCreateUsersWithArrayInput(List user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUsersWithArrayInput(List user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUsersWithArrayInputDefaultImplementation(ICreateUsersWithArrayInputApiResponse apiResponseLocalVar, List user) + { + bool suppressDefaultLog = false; + AfterCreateUsersWithArrayInput(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUsersWithArrayInput(ref bool suppressDefaultLog, ICreateUsersWithArrayInputApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUsersWithArrayInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) + { + bool suppressDefaultLog = false; + OnErrorCreateUsersWithArrayInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithArrayInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithArrayInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUsersWithArrayInputAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithArrayInputAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUsersWithArrayInput(user); + + FormatCreateUsersWithArrayInput(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/createWithArray"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUsersWithArrayInputApiResponse apiResponseLocalVar = new CreateUsersWithArrayInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithArray", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUsersWithArrayInputDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUsersWithArrayInput(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUsersWithArrayInputDefaultImplementation(e, "/user/createWithArray", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithArrayInput(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUsersWithArrayInputApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUsersWithArrayInputApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUsersWithArrayInputApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatCreateUsersWithListInput(List user); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateCreateUsersWithListInput(List user) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterCreateUsersWithListInputDefaultImplementation(ICreateUsersWithListInputApiResponse apiResponseLocalVar, List user) + { + bool suppressDefaultLog = false; + AfterCreateUsersWithListInput(ref suppressDefaultLog, apiResponseLocalVar, user); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterCreateUsersWithListInput(ref bool suppressDefaultLog, ICreateUsersWithListInputApiResponse apiResponseLocalVar, List user); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorCreateUsersWithListInputDefaultImplementation(Exception exception, string pathFormat, string path, List user) + { + bool suppressDefaultLog = false; + OnErrorCreateUsersWithListInput(ref suppressDefaultLog, exception, pathFormat, path, user); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorCreateUsersWithListInput(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, List user); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithListInputOrDefaultAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await CreateUsersWithListInputAsync(user, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Creates list of users with given input array + /// + /// Thrown when fails to make API call + /// List of user object + /// Cancellation Token to cancel the request. + /// <> + public async Task CreateUsersWithListInputAsync(List user, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateCreateUsersWithListInput(user); + + FormatCreateUsersWithListInput(user); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/createWithList"; + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("POST"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + CreateUsersWithListInputApiResponse apiResponseLocalVar = new CreateUsersWithListInputApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/createWithList", requestedAtLocalVar, _jsonSerializerOptions); + + AfterCreateUsersWithListInputDefaultImplementation(apiResponseLocalVar, user); + + Events.ExecuteOnCreateUsersWithListInput(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorCreateUsersWithListInputDefaultImplementation(e, "/user/createWithList", uriBuilderLocalVar.Path, user); + Events.ExecuteOnErrorCreateUsersWithListInput(e); + throw; + } + } + + /// + /// The + /// + public partial class CreateUsersWithListInputApiResponse : Org.OpenAPITools.Client.ApiResponse, ICreateUsersWithListInputApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public CreateUsersWithListInputApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatDeleteUser(ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateDeleteUser(string username) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterDeleteUserDefaultImplementation(IDeleteUserApiResponse apiResponseLocalVar, string username) + { + bool suppressDefaultLog = false; + AfterDeleteUser(ref suppressDefaultLog, apiResponseLocalVar, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterDeleteUser(ref bool suppressDefaultLog, IDeleteUserApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorDeleteUserDefaultImplementation(Exception exception, string pathFormat, string path, string username) + { + bool suppressDefaultLog = false; + OnErrorDeleteUser(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorDeleteUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteUserOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await DeleteUserAsync(username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// The name that needs to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task DeleteUserAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateDeleteUser(username); + + FormatDeleteUser(ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("DELETE"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + DeleteUserApiResponse apiResponseLocalVar = new DeleteUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterDeleteUserDefaultImplementation(apiResponseLocalVar, username); + + Events.ExecuteOnDeleteUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorDeleteUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorDeleteUser(e); + throw; + } + } + + /// + /// The + /// + public partial class DeleteUserApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public DeleteUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatGetUserByName(ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + private void ValidateGetUserByName(string username) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + private void AfterGetUserByNameDefaultImplementation(IGetUserByNameApiResponse apiResponseLocalVar, string username) + { + bool suppressDefaultLog = false; + AfterGetUserByName(ref suppressDefaultLog, apiResponseLocalVar, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + partial void AfterGetUserByName(ref bool suppressDefaultLog, IGetUserByNameApiResponse apiResponseLocalVar, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + private void OnErrorGetUserByNameDefaultImplementation(Exception exception, string pathFormat, string path, string username) + { + bool suppressDefaultLog = false; + OnErrorGetUserByName(ref suppressDefaultLog, exception, pathFormat, path, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + partial void OnErrorGetUserByName(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username); + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + public async Task GetUserByNameOrDefaultAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetUserByNameAsync(username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Get user by user name + /// + /// Thrown when fails to make API call + /// The name that needs to be fetched. Use user1 for testing. + /// Cancellation Token to cancel the request. + /// <> + public async Task GetUserByNameAsync(string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateGetUserByName(username); + + FormatGetUserByName(ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetUserByNameApiResponse apiResponseLocalVar = new GetUserByNameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetUserByNameDefaultImplementation(apiResponseLocalVar, username); + + Events.ExecuteOnGetUserByName(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetUserByNameDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, username); + Events.ExecuteOnErrorGetUserByName(e); + throw; + } + } + + /// + /// The + /// + public partial class GetUserByNameApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetUserByNameApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetUserByNameApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.User Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.User result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + /// + /// Returns true if the response is 598 CustomHttpStatusCode598 + /// + /// + public bool IsCustomHttpStatusCode598 => 598 == (int)StatusCode; + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 + /// + /// + public bool IsCustomHttpStatusCode599 => 599 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 599 CustomHttpStatusCode599 + /// + /// + public Org.OpenAPITools.Model.User CustomHttpStatusCode599() + { + // This logic may be modified with the AsModel.mustache template + return IsCustomHttpStatusCode599 + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 599 CustomHttpStatusCode599 and the deserialized response is not null + /// + /// + /// + public bool TryCustomHttpStatusCode599(out Org.OpenAPITools.Model.User result) + { + result = null; + + try + { + result = CustomHttpStatusCode599(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)599); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatLoginUser(ref string username, ref string password); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateLoginUser(string username, string password) + { + if (username == null) + throw new ArgumentNullException(nameof(username)); + + if (password == null) + throw new ArgumentNullException(nameof(password)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterLoginUserDefaultImplementation(ILoginUserApiResponse apiResponseLocalVar, string username, string password) + { + bool suppressDefaultLog = false; + AfterLoginUser(ref suppressDefaultLog, apiResponseLocalVar, username, password); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterLoginUser(ref bool suppressDefaultLog, ILoginUserApiResponse apiResponseLocalVar, string username, string password); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorLoginUserDefaultImplementation(Exception exception, string pathFormat, string path, string username, string password) + { + bool suppressDefaultLog = false; + OnErrorLoginUser(ref suppressDefaultLog, exception, pathFormat, path, username, password); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorLoginUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string username, string password); + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + public async Task LoginUserOrDefaultAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await LoginUserAsync(username, password, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Logs user into the system + /// + /// Thrown when fails to make API call + /// The user name for login + /// The password for login in clear text + /// Cancellation Token to cancel the request. + /// <> + public async Task LoginUserAsync(string username, string password, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateLoginUser(username, password); + + FormatLoginUser(ref username, ref password); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/login"; + + System.Collections.Specialized.NameValueCollection parseQueryStringLocalVar = System.Web.HttpUtility.ParseQueryString(string.Empty); + + parseQueryStringLocalVar["username"] = ClientUtils.ParameterToString(username); + parseQueryStringLocalVar["password"] = ClientUtils.ParameterToString(password); + + uriBuilderLocalVar.Query = parseQueryStringLocalVar.ToString(); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/xml", + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + LoginUserApiResponse apiResponseLocalVar = new LoginUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/login", requestedAtLocalVar, _jsonSerializerOptions); + + AfterLoginUserDefaultImplementation(apiResponseLocalVar, username, password); + + Events.ExecuteOnLoginUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorLoginUserDefaultImplementation(e, "/user/login", uriBuilderLocalVar.Path, username, password); + Events.ExecuteOnErrorLoginUser(e); + throw; + } + } + + /// + /// The + /// + public partial class LoginUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ILoginUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public LoginUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public string Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out string result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterLogoutUserDefaultImplementation(ILogoutUserApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterLogoutUser(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterLogoutUser(ref bool suppressDefaultLog, ILogoutUserApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorLogoutUserDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorLogoutUser(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorLogoutUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Logs out current logged in user session + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task LogoutUserOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await LogoutUserAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Logs out current logged in user session + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task LogoutUserAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/logout"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + LogoutUserApiResponse apiResponseLocalVar = new LogoutUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/logout", requestedAtLocalVar, _jsonSerializerOptions); + + AfterLogoutUserDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnLogoutUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorLogoutUserDefaultImplementation(e, "/user/logout", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorLogoutUser(e); + throw; + } + } + + /// + /// The + /// + public partial class LogoutUserApiResponse : Org.OpenAPITools.Client.ApiResponse, ILogoutUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public LogoutUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is the default response type + /// + /// + public bool IsDefault => true; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + partial void FormatUpdateUser(User user, ref string username); + + /// + /// Validates the request parameters + /// + /// + /// + /// + private void ValidateUpdateUser(User user, string username) + { + if (user == null) + throw new ArgumentNullException(nameof(user)); + + if (username == null) + throw new ArgumentNullException(nameof(username)); + } + + /// + /// Processes the server response + /// + /// + /// + /// + private void AfterUpdateUserDefaultImplementation(IUpdateUserApiResponse apiResponseLocalVar, User user, string username) + { + bool suppressDefaultLog = false; + AfterUpdateUser(ref suppressDefaultLog, apiResponseLocalVar, user, username); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + partial void AfterUpdateUser(ref bool suppressDefaultLog, IUpdateUserApiResponse apiResponseLocalVar, User user, string username); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + /// + /// + private void OnErrorUpdateUserDefaultImplementation(Exception exception, string pathFormat, string path, User user, string username) + { + bool suppressDefaultLog = false; + OnErrorUpdateUser(ref suppressDefaultLog, exception, pathFormat, path, user, username); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + /// + /// + partial void OnErrorUpdateUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, User user, string username); + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdateUserOrDefaultAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await UpdateUserAsync(user, username, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// Thrown when fails to make API call + /// Updated user object + /// name that need to be deleted + /// Cancellation Token to cancel the request. + /// <> + public async Task UpdateUserAsync(User user, string username, System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + ValidateUpdateUser(user, username); + + FormatUpdateUser(user, ref username); + + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/user/{username}"; + uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7Busername%7D", Uri.EscapeDataString(username.ToString())); + + httpRequestMessageLocalVar.Content = (user as object) is System.IO.Stream stream + ? httpRequestMessageLocalVar.Content = new StreamContent(stream) + : httpRequestMessageLocalVar.Content = new StringContent(JsonSerializer.Serialize(user, _jsonSerializerOptions)); + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] contentTypes = new string[] { + "application/json" + }; + + string contentTypeLocalVar = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentTypeLocalVar != null && httpRequestMessageLocalVar.Content != null) + httpRequestMessageLocalVar.Content.Headers.ContentType = new MediaTypeHeaderValue(contentTypeLocalVar); + + httpRequestMessageLocalVar.Method = new HttpMethod("PUT"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + UpdateUserApiResponse apiResponseLocalVar = new UpdateUserApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/user/{username}", requestedAtLocalVar, _jsonSerializerOptions); + + AfterUpdateUserDefaultImplementation(apiResponseLocalVar, user, username); + + Events.ExecuteOnUpdateUser(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorUpdateUserDefaultImplementation(e, "/user/{username}", uriBuilderLocalVar.Path, user, username); + Events.ExecuteOnErrorUpdateUser(e); + throw; + } + } + + /// + /// The + /// + public partial class UpdateUserApiResponse : Org.OpenAPITools.Client.ApiResponse, IUpdateUserApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public UpdateUserApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 400 BadRequest + /// + /// + public bool IsBadRequest => 400 == (int)StatusCode; + + /// + /// Returns true if the response is 404 NotFound + /// + /// + public bool IsNotFound => 404 == (int)StatusCode; + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..fdd11dd19c9a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiKeyToken.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiKeyToken.cs new file mode 100644 index 000000000000..b8bdf9964ffb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiKeyToken.cs @@ -0,0 +1,52 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from an apiKey. + /// + public class ApiKeyToken : TokenBase + { + private string _raw; + + /// + /// The header that this token will be used with. + /// + public ClientUtils.ApiKeyHeader Header { get; } + + /// + /// Constructs an ApiKeyToken object. + /// + /// + /// + /// + /// + public ApiKeyToken(string value, ClientUtils.ApiKeyHeader header, string prefix = "Bearer ", TimeSpan? timeout = null) : base(timeout) + { + Header = header; + _raw = $"{ prefix }{ value }"; + } + + /// + /// Places the token in the header. + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request) + { + request.Headers.Add(ClientUtils.ApiKeyHeaderToString(Header), _raw); + } + + /// + /// Places the token in the query. + /// + /// + /// + /// + public virtual void UseInQuery(System.Net.Http.HttpRequestMessage request, UriBuilder uriBuilder, System.Collections.Specialized.NameValueCollection parseQueryString) + { + parseQueryString[ClientUtils.ApiKeyHeaderToString(Header)] = Uri.EscapeDataString(_raw).ToString(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..63c4e7c4bc3a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,210 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface ICustomHttpStatusCode599 : IApiResponse + { + /// + /// Deserializes the response if the response is CustomHttpStatusCode599 + /// + /// + TType CustomHttpStatusCode599(); + + /// + /// Returns true if the response is CustomHttpStatusCode599 and the deserialized response is not null + /// + /// + /// + bool TryCustomHttpStatusCode599(out TType result); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } + + /// + /// An interface for responses of type + /// + /// + public interface IDefault : IApiResponse + { + /// + /// Deserializes the response if the response is Default + /// + /// + TType Default(); + + /// + /// Returns true if the response is Default and the deserialized response is not null + /// + /// + /// + bool TryDefault(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BasicToken.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BasicToken.cs new file mode 100644 index 000000000000..c58c0563231f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BasicToken.cs @@ -0,0 +1,42 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from a username and password. + /// + public class BasicToken : TokenBase + { + private string _username; + + private string _password; + + /// + /// Constructs a BasicToken object. + /// + /// + /// + /// + public BasicToken(string username, string password, TimeSpan? timeout = null) : base(timeout) + { + _username = username; + + _password = password; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Org.OpenAPITools.Client.ClientUtils.Base64Encode(_username + ":" + _password)); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BearerToken.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BearerToken.cs new file mode 100644 index 000000000000..df5c2310bacd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/BearerToken.cs @@ -0,0 +1,37 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from a token from a bearer token. + /// + public class BearerToken : TokenBase + { + private string _raw; + + /// + /// Constructs a BearerToken object. + /// + /// + /// + public BearerToken(string value, TimeSpan? timeout = null) : base(timeout) + { + _raw = value; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _raw); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..9cb9620cc920 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,427 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using KellermanSoftware.CompareNetObjects; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + /// + /// An instance of CompareLogic. + /// + public static CompareLogic compareLogic; + + /// + /// Static constructor to initialise compareLogic. + /// + static ClientUtils() + { + ComparisonConfig comparisonConfig = new ComparisonConfig(); + comparisonConfig.UseHashCodeIdentifier = true; + compareLogic = new CompareLogic(comparisonConfig); + } + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// An enum of headers + /// + public enum ApiKeyHeader + { + /// + /// The api_key header + /// + Api_key, + /// + /// The api_key_query header + /// + Api_key_query + } + + /// + /// Converte an ApiKeyHeader to a string + /// + /// + /// + /// + public static string ApiKeyHeaderToString(ApiKeyHeader value) + { + switch(value) + { + case ApiKeyHeader.Api_key: + return "api_key"; + case ApiKeyHeader.Api_key_query: + return "api_key_query"; + default: + throw new System.ComponentModel.InvalidEnumArgumentException(nameof(value), (int)value, typeof(ApiKeyHeader)); + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) + return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) + return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); + if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) + return EnumArrays.JustSymbolEnumToJsonValue(enumArraysJustSymbolEnum); + if (obj is EnumClass enumClass) + return EnumClassValueConverter.ToJsonValue(enumClass); + if (obj is EnumTest.EnumStringRequiredEnum enumTestEnumStringRequiredEnum) + return EnumTest.EnumStringRequiredEnumToJsonValue(enumTestEnumStringRequiredEnum); + if (obj is EnumTest.EnumIntegerEnum enumTestEnumIntegerEnum) + return EnumTest.EnumIntegerEnumToJsonValue(enumTestEnumIntegerEnum).ToString(); + if (obj is EnumTest.EnumIntegerOnlyEnum enumTestEnumIntegerOnlyEnum) + return EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTestEnumIntegerOnlyEnum).ToString(); + if (obj is EnumTest.EnumNumberEnum enumTestEnumNumberEnum) + return EnumTest.EnumNumberEnumToJsonValue(enumTestEnumNumberEnum).ToString(); + if (obj is EnumTest.EnumStringEnum enumTestEnumStringEnum) + return EnumTest.EnumStringEnumToJsonValue(enumTestEnumStringEnum); + if (obj is MapTest.InnerEnum mapTestInnerEnum) + return MapTest.InnerEnumToJsonValue(mapTestInnerEnum); + if (obj is Order.StatusEnum orderStatusEnum) + return Order.StatusEnumToJsonValue(orderStatusEnum); + if (obj is OuterEnum outerEnum) + return OuterEnumValueConverter.ToJsonValue(outerEnum); + if (obj is OuterEnumDefaultValue outerEnumDefaultValue) + return OuterEnumDefaultValueValueConverter.ToJsonValue(outerEnumDefaultValue); + if (obj is OuterEnumInteger outerEnumInteger) + return OuterEnumIntegerValueConverter.ToJsonValue(outerEnumInteger).ToString(); + if (obj is OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue) + return OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(outerEnumIntegerDefaultValue).ToString(); + if (obj is OuterEnumTest outerEnumTest) + return OuterEnumTestValueConverter.ToJsonValue(outerEnumTest); + if (obj is Pet.StatusEnum petStatusEnum) + return Pet.StatusEnumToJsonValue(petStatusEnum); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerEnum requiredClassRequiredNotnullableEnumIntegerEnum) + return RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum requiredClassRequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNotnullableEnumStringEnum requiredClassRequiredNotnullableEnumStringEnum) + return RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClassRequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerEnum requiredClassNotrequiredNotnullableEnumIntegerEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNotnullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNotnullableEnumStringEnum requiredClassNotrequiredNotnullableEnumStringEnum) + return RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClassNotrequiredNotnullableEnumStringEnum); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerEnum requiredClassNotrequiredNullableEnumIntegerEnum) + return RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum requiredClassNotrequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassNotrequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.NotrequiredNullableEnumStringEnum requiredClassNotrequiredNullableEnumStringEnum) + return RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClassNotrequiredNullableEnumStringEnum); + if (obj is RequiredClass.RequiredNullableEnumIntegerEnum requiredClassRequiredNullableEnumIntegerEnum) + return RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClassRequiredNullableEnumIntegerEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumIntegerOnlyEnum requiredClassRequiredNullableEnumIntegerOnlyEnum) + return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); + if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) + return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is Zebra.TypeEnum zebraTypeEnum) + return Zebra.TypeEnumToJsonValue(zebraTypeEnum); + if (obj is ZeroBasedEnum zeroBasedEnum) + return ZeroBasedEnumValueConverter.ToJsonValue(zeroBasedEnum); + if (obj is ZeroBasedEnumClass.ZeroBasedEnumEnum zeroBasedEnumClassZeroBasedEnumEnum) + return ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClassZeroBasedEnumEnum); + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://petstore.swagger.io:80/v2"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = "/v2"; + + /// + /// The host of the API + /// + public const string HOST = "petstore.swagger.io"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..973f9e9d4e80 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..b491c61f07fa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..8ea6690254f5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,244 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new ActivityJsonConverter()); + _jsonOptions.Converters.Add(new ActivityOutputElementRepresentationJsonConverter()); + _jsonOptions.Converters.Add(new AdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new AnimalJsonConverter()); + _jsonOptions.Converters.Add(new ApiResponseJsonConverter()); + _jsonOptions.Converters.Add(new AppleJsonConverter()); + _jsonOptions.Converters.Add(new AppleReqJsonConverter()); + _jsonOptions.Converters.Add(new ArrayOfArrayOfNumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ArrayOfNumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ArrayTestJsonConverter()); + _jsonOptions.Converters.Add(new BananaJsonConverter()); + _jsonOptions.Converters.Add(new BananaReqJsonConverter()); + _jsonOptions.Converters.Add(new BasquePigJsonConverter()); + _jsonOptions.Converters.Add(new CapitalizationJsonConverter()); + _jsonOptions.Converters.Add(new CatJsonConverter()); + _jsonOptions.Converters.Add(new CategoryJsonConverter()); + _jsonOptions.Converters.Add(new ChildCatJsonConverter()); + _jsonOptions.Converters.Add(new ClassModelJsonConverter()); + _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new DanishPigJsonConverter()); + _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); + _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); + _jsonOptions.Converters.Add(new DogJsonConverter()); + _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); + _jsonOptions.Converters.Add(new EnumClassJsonConverter()); + _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); + _jsonOptions.Converters.Add(new EnumTestJsonConverter()); + _jsonOptions.Converters.Add(new EquilateralTriangleJsonConverter()); + _jsonOptions.Converters.Add(new FileJsonConverter()); + _jsonOptions.Converters.Add(new FileSchemaTestClassJsonConverter()); + _jsonOptions.Converters.Add(new FooJsonConverter()); + _jsonOptions.Converters.Add(new FooGetDefaultResponseJsonConverter()); + _jsonOptions.Converters.Add(new FormatTestJsonConverter()); + _jsonOptions.Converters.Add(new FruitJsonConverter()); + _jsonOptions.Converters.Add(new FruitReqJsonConverter()); + _jsonOptions.Converters.Add(new GmFruitJsonConverter()); + _jsonOptions.Converters.Add(new GrandparentAnimalJsonConverter()); + _jsonOptions.Converters.Add(new HasOnlyReadOnlyJsonConverter()); + _jsonOptions.Converters.Add(new HealthCheckResultJsonConverter()); + _jsonOptions.Converters.Add(new IsoscelesTriangleJsonConverter()); + _jsonOptions.Converters.Add(new ListJsonConverter()); + _jsonOptions.Converters.Add(new LiteralStringClassJsonConverter()); + _jsonOptions.Converters.Add(new MammalJsonConverter()); + _jsonOptions.Converters.Add(new MapTestJsonConverter()); + _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); + _jsonOptions.Converters.Add(new ModelClientJsonConverter()); + _jsonOptions.Converters.Add(new NameJsonConverter()); + _jsonOptions.Converters.Add(new NotificationtestGetElementsV1ResponseMPayloadJsonConverter()); + _jsonOptions.Converters.Add(new NullableClassJsonConverter()); + _jsonOptions.Converters.Add(new NullableGuidClassJsonConverter()); + _jsonOptions.Converters.Add(new NullableShapeJsonConverter()); + _jsonOptions.Converters.Add(new NumberOnlyJsonConverter()); + _jsonOptions.Converters.Add(new ObjectWithDeprecatedFieldsJsonConverter()); + _jsonOptions.Converters.Add(new OneOfStringJsonConverter()); + _jsonOptions.Converters.Add(new OrderJsonConverter()); + _jsonOptions.Converters.Add(new OuterCompositeJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumDefaultValueJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumDefaultValueNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerDefaultValueJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumIntegerDefaultValueNullableJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumTestJsonConverter()); + _jsonOptions.Converters.Add(new OuterEnumTestNullableJsonConverter()); + _jsonOptions.Converters.Add(new ParentPetJsonConverter()); + _jsonOptions.Converters.Add(new PetJsonConverter()); + _jsonOptions.Converters.Add(new PigJsonConverter()); + _jsonOptions.Converters.Add(new PolymorphicPropertyJsonConverter()); + _jsonOptions.Converters.Add(new QuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); + _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ReturnJsonConverter()); + _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); + _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); + _jsonOptions.Converters.Add(new ScaleneTriangleJsonConverter()); + _jsonOptions.Converters.Add(new ShapeJsonConverter()); + _jsonOptions.Converters.Add(new ShapeInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new ShapeOrNullJsonConverter()); + _jsonOptions.Converters.Add(new SimpleQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new SpecialModelNameJsonConverter()); + _jsonOptions.Converters.Add(new TagJsonConverter()); + _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); + _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); + _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TriangleJsonConverter()); + _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); + _jsonOptions.Converters.Add(new UserJsonConverter()); + _jsonOptions.Converters.Add(new WhaleJsonConverter()); + _jsonOptions.Converters.Add(new ZebraJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumNullableJsonConverter()); + _jsonOptions.Converters.Add(new ZeroBasedEnumClassJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs new file mode 100644 index 000000000000..53f435c05f95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -0,0 +1,641 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Cryptography; +using System.Text; +using System.Web; + +namespace Org.OpenAPITools.Client +{ + /// + /// Class for HttpSigning auth related parameter and methods + /// + public class HttpSigningConfiguration + { + /// + /// Create an instance + /// + public HttpSigningConfiguration(string keyId, string keyFilePath, SecureString keyPassPhrase, List httpSigningHeader, HashAlgorithmName hashAlgorithm, string signingAlgorithm, int signatureValidityPeriod) + { + KeyId = keyId; + KeyFilePath = keyFilePath; + KeyPassPhrase = keyPassPhrase; + HttpSigningHeader = httpSigningHeader; + HashAlgorithm = hashAlgorithm; + SigningAlgorithm = signingAlgorithm; + SignatureValidityPeriod = signatureValidityPeriod; + } + + /// + ///Gets the Api keyId + /// + public string KeyId { get; set; } + + /// + /// Gets the Key file path + /// + public string KeyFilePath { get; set; } + + /// + /// Gets the key pass phrase for password protected key + /// + public SecureString KeyPassPhrase { get; set; } + + /// + /// Gets the HTTP signing header + /// + public List HttpSigningHeader { get; set; } + + /// + /// Gets the hash algorithm sha256 or sha512 + /// + public HashAlgorithmName HashAlgorithm { get; set; } = HashAlgorithmName.SHA256; + + /// + /// Gets the signing algorithm + /// + public string SigningAlgorithm { get; set; } + + /// + /// Gets the Signature validaty period in seconds + /// + public int SignatureValidityPeriod { get; set; } + + private enum PrivateKeyType + { + None = 0, + RSA = 1, + ECDSA = 2, + } + + /// + /// Gets the Headers for HttpSigning + /// + /// + /// + /// + internal Dictionary GetHttpSignedHeader(System.Net.Http.HttpRequestMessage request, string requestBody, System.Threading.CancellationToken cancellationToken = default) + { + if (request.RequestUri == null) + throw new NullReferenceException("The request URI was null"); + + const string HEADER_REQUEST_TARGET = "(request-target)"; + + // The time when the HTTP signature expires. The API server should reject HTTP requests that have expired. + const string HEADER_EXPIRES = "(expires)"; + + //The 'Date' header. + const string HEADER_DATE = "Date"; + + //The 'Host' header. + const string HEADER_HOST = "Host"; + + //The time when the HTTP signature was generated. + const string HEADER_CREATED = "(created)"; + + //When the 'Digest' header is included in the HTTP signature, the client automatically + //computes the digest of the HTTP request body, per RFC 3230. + const string HEADER_DIGEST = "Digest"; + + //The 'Authorization' header is automatically generated by the client. It includes + //the list of signed headers and a base64-encoded signature. + const string HEADER_AUTHORIZATION = "Authorization"; + + //Hash table to store singed headers + var HttpSignedRequestHeader = new Dictionary(); + + var httpSignatureHeader = new Dictionary(); + + if (HttpSigningHeader.Count == 0) + HttpSigningHeader.Add("(created)"); + + var dateTime = DateTime.Now; + string digest = String.Empty; + + if (HashAlgorithm == HashAlgorithmName.SHA256) + { + var bodyDigest = GetStringHash(HashAlgorithm, requestBody); + digest = string.Format("SHA-256={0}", Convert.ToBase64String(bodyDigest)); + } + else if (HashAlgorithm == HashAlgorithmName.SHA512) + { + var bodyDigest = GetStringHash(HashAlgorithm, requestBody); + digest = string.Format("SHA-512={0}", Convert.ToBase64String(bodyDigest)); + } + else + throw new Exception(string.Format("{0} not supported", HashAlgorithm)); + + foreach (var header in HttpSigningHeader) + if (header.Equals(HEADER_REQUEST_TARGET)) + httpSignatureHeader.Add(header.ToLower(), request.RequestUri.ToString()); + else if (header.Equals(HEADER_EXPIRES)) + { + var expireDateTime = dateTime.AddSeconds(SignatureValidityPeriod); + httpSignatureHeader.Add(header.ToLower(), GetUnixTime(expireDateTime).ToString()); + } + else if (header.Equals(HEADER_DATE)) + { + var utcDateTime = dateTime.ToString("r").ToString(); + httpSignatureHeader.Add(header.ToLower(), utcDateTime); + HttpSignedRequestHeader.Add(HEADER_DATE, utcDateTime); + } + else if (header.Equals(HEADER_HOST)) + { + httpSignatureHeader.Add(header.ToLower(), request.RequestUri.ToString()); + HttpSignedRequestHeader.Add(HEADER_HOST, request.RequestUri.ToString()); + } + else if (header.Equals(HEADER_CREATED)) + httpSignatureHeader.Add(header.ToLower(), GetUnixTime(dateTime).ToString()); + else if (header.Equals(HEADER_DIGEST)) + { + HttpSignedRequestHeader.Add(HEADER_DIGEST, digest); + httpSignatureHeader.Add(header.ToLower(), digest); + } + else + { + bool isHeaderFound = false; + foreach (var item in request.Headers) + { + if (string.Equals(item.Key, header, StringComparison.OrdinalIgnoreCase)) + { + httpSignatureHeader.Add(header.ToLower(), item.Value.ToString()); + isHeaderFound = true; + break; + } + } + + if (!isHeaderFound) + throw new Exception(string.Format("Cannot sign HTTP request.Request does not contain the {0} header.",header)); + } + + var headersKeysString = String.Join(" ", httpSignatureHeader.Keys); + var headerValuesList = new List(); + + foreach (var keyVal in httpSignatureHeader) + headerValuesList.Add(string.Format("{0}: {1}", keyVal.Key, keyVal.Value)); + + //Concatenate headers value separated by new line + var headerValuesString = string.Join("\n", headerValuesList); + var signatureStringHash = GetStringHash(HashAlgorithm, headerValuesString); + string headerSignatureStr = null; + var keyType = GetKeyType(KeyFilePath); + + if (keyType == PrivateKeyType.RSA) + headerSignatureStr = GetRSASignature(signatureStringHash); + + else if (keyType == PrivateKeyType.ECDSA) + headerSignatureStr = GetECDSASignature(signatureStringHash); + + var cryptographicScheme = "hs2019"; + var authorizationHeaderValue = string.Format("Signature keyId=\"{0}\",algorithm=\"{1}\"", + KeyId, cryptographicScheme); + + if (httpSignatureHeader.ContainsKey(HEADER_CREATED)) + authorizationHeaderValue += string.Format(",created={0}", httpSignatureHeader[HEADER_CREATED]); + + if (httpSignatureHeader.ContainsKey(HEADER_EXPIRES)) + authorizationHeaderValue += string.Format(",expires={0}", httpSignatureHeader[HEADER_EXPIRES]); + + authorizationHeaderValue += string.Format(",headers=\"{0}\",signature=\"{1}\"", headersKeysString, headerSignatureStr); + + HttpSignedRequestHeader.Add(HEADER_AUTHORIZATION, authorizationHeaderValue); + + return HttpSignedRequestHeader; + } + + private byte[] GetStringHash(HashAlgorithmName hashAlgorithmName, string stringToBeHashed) + { + HashAlgorithm hashAlgorithm = null; + + if (hashAlgorithmName == HashAlgorithmName.SHA1) + hashAlgorithm = SHA1.Create(); + + if (hashAlgorithmName == HashAlgorithmName.SHA256) + hashAlgorithm = SHA256.Create(); + + if (hashAlgorithmName == HashAlgorithmName.SHA512) + hashAlgorithm = SHA512.Create(); + + if (hashAlgorithmName == HashAlgorithmName.MD5) + hashAlgorithm = MD5.Create(); + + if (hashAlgorithm == null) + throw new NullReferenceException($"{ nameof(hashAlgorithm) } was null."); + + byte[] bytes = Encoding.UTF8.GetBytes(stringToBeHashed); + byte[] stringHash = hashAlgorithm.ComputeHash(bytes); + return stringHash; + } + + private int GetUnixTime(DateTime date2) + { + DateTime date1 = new DateTime(1970, 01, 01); + TimeSpan timeSpan = date2 - date1; + return (int)timeSpan.TotalSeconds; + } + + private string GetRSASignature(byte[] stringToSign) + { + if (KeyPassPhrase == null) + throw new NullReferenceException($"{ nameof(KeyPassPhrase) } was null."); + + RSA rsa = GetRSAProviderFromPemFile(KeyFilePath, KeyPassPhrase); + + if (rsa == null) + return string.Empty; + else if (SigningAlgorithm == "RSASSA-PSS") + { + var signedbytes = rsa.SignHash(stringToSign, HashAlgorithm, RSASignaturePadding.Pss); + return Convert.ToBase64String(signedbytes); + } + else if (SigningAlgorithm == "PKCS1-v15") + { + var signedbytes = rsa.SignHash(stringToSign, HashAlgorithm, RSASignaturePadding.Pkcs1); + return Convert.ToBase64String(signedbytes); + } + + return string.Empty; + } + + /// + /// Gets the ECDSA signature + /// + /// + /// + private string GetECDSASignature(byte[] dataToSign) + { + throw new Exception("ECDSA signing is supported only on NETCOREAPP3_0 and above"); + } + + private byte[] ConvertToECDSAANS1Format(byte[] signedBytes) + { + var derBytes = new List(); + byte derLength = 68; //default length for ECDSA code signing bit 0x44 + byte rbytesLength = 32; //R length 0x20 + byte sbytesLength = 32; //S length 0x20 + var rBytes = new List(); + var sBytes = new List(); + for (int i = 0; i < 32; i++) + rBytes.Add(signedBytes[i]); + + for (int i = 32; i < 64; i++) + sBytes.Add(signedBytes[i]); + + if (rBytes[0] > 0x7F) + { + derLength++; + rbytesLength++; + var tempBytes = new List(); + tempBytes.AddRange(rBytes); + rBytes.Clear(); + rBytes.Add(0x00); + rBytes.AddRange(tempBytes); + } + + if (sBytes[0] > 0x7F) + { + derLength++; + sbytesLength++; + var tempBytes = new List(); + tempBytes.AddRange(sBytes); + sBytes.Clear(); + sBytes.Add(0x00); + sBytes.AddRange(tempBytes); + + } + + derBytes.Add(48); //start of the sequence 0x30 + derBytes.Add(derLength); //total length r length, type and r bytes + + derBytes.Add(2); //tag for integer + derBytes.Add(rbytesLength); //length of r + derBytes.AddRange(rBytes); + + derBytes.Add(2); //tag for integer + derBytes.Add(sbytesLength); //length of s + derBytes.AddRange(sBytes); + return derBytes.ToArray(); + } + + private RSACryptoServiceProvider GetRSAProviderFromPemFile(String pemfile, SecureString keyPassPhrase = null) + { + const String pempubheader = "-----BEGIN PUBLIC KEY-----"; + const String pempubfooter = "-----END PUBLIC KEY-----"; + bool isPrivateKeyFile = true; + byte[] pemkey = null; + + if (!File.Exists(pemfile)) + throw new Exception("private key file does not exist."); + + string pemstr = File.ReadAllText(pemfile).Trim(); + + if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) + isPrivateKeyFile = false; + + if (isPrivateKeyFile) + { + pemkey = ConvertPrivateKeyToBytes(pemstr, keyPassPhrase); + + if (pemkey == null) + return null; + + return DecodeRSAPrivateKey(pemkey); + } + return null; + } + + private byte[] ConvertPrivateKeyToBytes(String instr, SecureString keyPassPhrase = null) + { + const String pemprivheader = "-----BEGIN RSA PRIVATE KEY-----"; + const String pemprivfooter = "-----END RSA PRIVATE KEY-----"; + String pemstr = instr.Trim(); + byte[] binkey; + + if (!pemstr.StartsWith(pemprivheader) || !pemstr.EndsWith(pemprivfooter)) + return null; + + StringBuilder sb = new StringBuilder(pemstr); + sb.Replace(pemprivheader, ""); + sb.Replace(pemprivfooter, ""); + String pvkstr = sb.ToString().Trim(); + + try + { // if there are no PEM encryption info lines, this is an UNencrypted PEM private key + binkey = Convert.FromBase64String(pvkstr); + return binkey; + } + catch (System.FormatException) + { + StringReader str = new StringReader(pvkstr); + + //-------- read PEM encryption info. lines and extract salt ----- + if (!str.ReadLine().StartsWith("Proc-Type: 4,ENCRYPTED")) // TODO: what do we do here if ReadLine is null? + return null; + + String saltline = str.ReadLine(); // TODO: what do we do here if ReadLine is null? + if (!saltline.StartsWith("DEK-Info: DES-EDE3-CBC,")) + return null; + + String saltstr = saltline.Substring(saltline.IndexOf(",") + 1).Trim(); + byte[] salt = new byte[saltstr.Length / 2]; + for (int i = 0; i < salt.Length; i++) + salt[i] = Convert.ToByte(saltstr.Substring(i * 2, 2), 16); + + if (!(str.ReadLine() == "")) + return null; + + //------ remaining b64 data is encrypted RSA key ---- + String encryptedstr = str.ReadToEnd(); + + try + { //should have b64 encrypted RSA key now + binkey = Convert.FromBase64String(encryptedstr); + } + catch (System.FormatException) + { //data is not in base64 format + return null; + } + + // TODO: what do we do here if keyPassPhrase is null? + byte[] deskey = GetEncryptedKey(salt, keyPassPhrase, 1, 2); // count=1 (for OpenSSL implementation); 2 iterations to get at least 24 bytes + if (deskey == null) + return null; + + //------ Decrypt the encrypted 3des-encrypted RSA private key ------ + byte[] rsakey = DecryptKey(binkey, deskey, salt); //OpenSSL uses salt value in PEM header also as 3DES IV + + return rsakey; + } + } + + private RSACryptoServiceProvider DecodeRSAPrivateKey(byte[] privkey) + { + byte[] MODULUS, E, D, P, Q, DP, DQ, IQ; + + // --------- Set up stream to decode the asn.1 encoded RSA private key ------ + MemoryStream mem = new MemoryStream(privkey); + BinaryReader binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading + byte bt = 0; + ushort twobytes = 0; + int elems = 0; + try + { + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + return null; + + twobytes = binr.ReadUInt16(); + if (twobytes != 0x0102) //version number + return null; + + bt = binr.ReadByte(); + if (bt != 0x00) + return null; + + //------ all private key components are Integer sequences ---- + elems = GetIntegerSize(binr); + MODULUS = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + E = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + D = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + P = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + Q = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + DP = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + DQ = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + IQ = binr.ReadBytes(elems); + + // ------- create RSACryptoServiceProvider instance and initialize with public key ----- + RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); + RSAParameters RSAparams = new RSAParameters(); + RSAparams.Modulus = MODULUS; + RSAparams.Exponent = E; + RSAparams.D = D; + RSAparams.P = P; + RSAparams.Q = Q; + RSAparams.DP = DP; + RSAparams.DQ = DQ; + RSAparams.InverseQ = IQ; + RSA.ImportParameters(RSAparams); + return RSA; + } + catch (Exception) + { + return null; + } + finally + { + binr.Close(); + } + } + + private int GetIntegerSize(BinaryReader binr) + { + byte bt = 0; + byte lowbyte = 0x00; + byte highbyte = 0x00; + int count = 0; + bt = binr.ReadByte(); + if (bt != 0x02) //expect integer + return 0; + + bt = binr.ReadByte(); + + if (bt == 0x81) + count = binr.ReadByte(); // data size in next byte + else if (bt == 0x82) + { + highbyte = binr.ReadByte(); // data size in next 2 bytes + lowbyte = binr.ReadByte(); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; + count = BitConverter.ToInt32(modint, 0); + } + else + count = bt; // we already have the data size + + while (binr.ReadByte() == 0x00) + //remove high order zeros in data + count -= 1; + + binr.BaseStream.Seek(-1, SeekOrigin.Current); + + //last ReadByte wasn't a removed zero, so back up a byte + return count; + } + + private byte[] GetEncryptedKey(byte[] salt, SecureString secpswd, int count, int miter) + { + IntPtr unmanagedPswd = IntPtr.Zero; + int HASHLENGTH = 16; //MD5 bytes + byte[] keymaterial = new byte[HASHLENGTH * miter]; //to store concatenated Mi hashed results + + byte[] psbytes = new byte[secpswd.Length]; + unmanagedPswd = Marshal.SecureStringToGlobalAllocAnsi(secpswd); + Marshal.Copy(unmanagedPswd, psbytes, 0, psbytes.Length); + Marshal.ZeroFreeGlobalAllocAnsi(unmanagedPswd); + + // --- concatenate salt and pswd bytes into fixed data array --- + byte[] data00 = new byte[psbytes.Length + salt.Length]; + Array.Copy(psbytes, data00, psbytes.Length); //copy the pswd bytes + Array.Copy(salt, 0, data00, psbytes.Length, salt.Length); //concatenate the salt bytes + + // ---- do multi-hashing and concatenate results D1, D2 ... into keymaterial bytes ---- + MD5 md5 = MD5.Create(); + byte[] result = null; + byte[] hashtarget = new byte[HASHLENGTH + data00.Length]; //fixed length initial hashtarget + + for (int j = 0; j < miter; j++) + { + // ---- Now hash consecutively for count times ------ + if (j == 0) + result = data00; //initialize + else + { + Array.Copy(result, hashtarget, result.Length); // TODO: what do we do if result is null here? + Array.Copy(data00, 0, hashtarget, result.Length, data00.Length); + result = hashtarget; + } + + for (int i = 0; i < count; i++) + result = md5.ComputeHash(result); + + Array.Copy(result, 0, keymaterial, j * HASHLENGTH, result.Length); //concatenate to keymaterial + } + byte[] deskey = new byte[24]; + Array.Copy(keymaterial, deskey, deskey.Length); + + Array.Clear(psbytes, 0, psbytes.Length); + Array.Clear(data00, 0, data00.Length); + Array.Clear(result, 0, result.Length); // TODO: what do we do if result is null here? + Array.Clear(hashtarget, 0, hashtarget.Length); + Array.Clear(keymaterial, 0, keymaterial.Length); + return deskey; + } + + private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) + { + MemoryStream memst = new MemoryStream(); + TripleDES alg = TripleDES.Create(); + alg.Key = desKey; + alg.IV = IV; + try + { + CryptoStream cs = new CryptoStream(memst, alg.CreateDecryptor(), CryptoStreamMode.Write); + cs.Write(cipherData, 0, cipherData.Length); + cs.Close(); + } + catch (Exception) + { + return null; + } + byte[] decryptedData = memst.ToArray(); + return decryptedData; + } + + /// + /// Detect the key type from the pem file. + /// + /// key file path in pem format + /// + private PrivateKeyType GetKeyType(string keyFilePath) + { + if (!File.Exists(keyFilePath)) + throw new Exception("Key file path does not exist."); + + var ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; + var ecPrivateKeyFooter = "END EC PRIVATE KEY"; + var rsaPrivateKeyHeader = "BEGIN RSA PRIVATE KEY"; + var rsaPrivateFooter = "END RSA PRIVATE KEY"; + //var pkcs8Header = "BEGIN PRIVATE KEY"; + //var pkcs8Footer = "END PRIVATE KEY"; + var keyType = PrivateKeyType.None; + var key = File.ReadAllLines(keyFilePath); + + if (key[0].ToString().Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) + keyType = PrivateKeyType.RSA; + else if (key[0].ToString().Contains(ecPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(ecPrivateKeyFooter)) + keyType = PrivateKeyType.ECDSA; + + else if (key[0].ToString().Contains(ecPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(ecPrivateKeyFooter)) + { + /* this type of key can hold many type different types of private key, but here due lack of pem header + Considering this as EC key + */ + //TODO :- update the key based on oid + keyType = PrivateKeyType.ECDSA; + } + else + throw new Exception("Either the key is invalid or key is not supported"); + + return keyType; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningToken.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningToken.cs new file mode 100644 index 000000000000..b6301dc17c95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningToken.cs @@ -0,0 +1,41 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed from an HttpSigningConfiguration + /// + public class HttpSignatureToken : TokenBase + { + private HttpSigningConfiguration _configuration; + + /// + /// Constructs an HttpSignatureToken object. + /// + /// + /// + public HttpSignatureToken(HttpSigningConfiguration configuration, TimeSpan? timeout = null) : base(timeout) + { + _configuration = configuration; + } + + /// + /// Places the token in the header. + /// + /// + /// + /// + public void UseInHeader(System.Net.Http.HttpRequestMessage request, string requestBody, CancellationToken cancellationToken = default) + { + var signedHeaders = _configuration.GetHttpSignedHeader(request, requestBody, cancellationToken); + + foreach (var signedHeader in signedHeaders) + request.Headers.Add(signedHeader.Key, signedHeader.Value); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/OAuthToken.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/OAuthToken.cs new file mode 100644 index 000000000000..ec4d08e9c99a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/OAuthToken.cs @@ -0,0 +1,37 @@ +// + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Org.OpenAPITools.Client +{ + /// + /// A token constructed with OAuth. + /// + public class OAuthToken : TokenBase + { + private string _raw; + + /// + /// Consturcts an OAuthToken object. + /// + /// + /// + public OAuthToken(string value, TimeSpan? timeout = null) : base(timeout) + { + _raw = value; + } + + /// + /// Places the token in the header. + /// + /// + /// + public virtual void UseInHeader(System.Net.Http.HttpRequestMessage request, string headerName) + { + request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _raw); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..8cf79a713b74 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..534f27a8cc52 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,72 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + if (container is TokenContainer apiKeyTokenContainer) + { + string[] headers = apiKeyTokenContainer.Tokens.Select(t => ClientUtils.ApiKeyHeaderToString(t.Header)).Distinct().ToArray(); + + foreach (string header in headers) + { + BoundedChannelOptions options = new BoundedChannelOptions(apiKeyTokenContainer.Tokens.Count(t => ClientUtils.ApiKeyHeaderToString(t.Header).Equals(header))) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(header, Channel.CreateBounded(options)); + } + } + else + { + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + } + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..36d7dad03e23 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..dce7b971eaac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,41 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..40eeffc96765 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..c82fea7a865d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs new file mode 100644 index 000000000000..2e4d5cb3bb8f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Activity.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// test map of maps + /// + public partial class Activity : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// activityOutputs + [JsonConstructor] + public Activity(Option>> activityOutputs = default) + { + ActivityOutputsOption = activityOutputs; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ActivityOutputs + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ActivityOutputsOption { get; private set; } + + /// + /// Gets or Sets ActivityOutputs + /// + [JsonPropertyName("activity_outputs")] + public Dictionary> ActivityOutputs { get { return this.ActivityOutputsOption; } set { this.ActivityOutputsOption = new Option>>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Activity {\n"); + sb.Append(" ActivityOutputs: ").Append(ActivityOutputs).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> activityOutputs = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "activity_outputs": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + activityOutputs = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (activityOutputs.IsSet && activityOutputs.Value == null) + throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity."); + + return new Activity(activityOutputs); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, activity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + { + if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null) + throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity."); + + if (activity.ActivityOutputsOption.IsSet) + { + writer.WritePropertyName("activity_outputs"); + JsonSerializer.Serialize(writer, activity.ActivityOutputs, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs new file mode 100644 index 000000000000..b24ba8678984 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -0,0 +1,207 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ActivityOutputElementRepresentation + /// + public partial class ActivityOutputElementRepresentation : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// prop1 + /// prop2 + [JsonConstructor] + public ActivityOutputElementRepresentation(Option prop1 = default, Option prop2 = default) + { + Prop1Option = prop1; + Prop2Option = prop2; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Prop1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop1Option { get; private set; } + + /// + /// Gets or Sets Prop1 + /// + [JsonPropertyName("prop1")] + public string Prop1 { get { return this.Prop1Option; } set { this.Prop1Option = new Option(value); } } + + /// + /// Used to track the state of Prop2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Prop2Option { get; private set; } + + /// + /// Gets or Sets Prop2 + /// + [JsonPropertyName("prop2")] + public Object Prop2 { get { return this.Prop2Option; } set { this.Prop2Option = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ActivityOutputElementRepresentation {\n"); + sb.Append(" Prop1: ").Append(Prop1).Append("\n"); + sb.Append(" Prop2: ").Append(Prop2).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ActivityOutputElementRepresentationJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option prop1 = default; + Option prop2 = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "prop1": + prop1 = new Option(utf8JsonReader.GetString()); + break; + case "prop2": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + prop2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (prop1.IsSet && prop1.Value == null) + throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation."); + + if (prop2.IsSet && prop2.Value == null) + throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation."); + + return new ActivityOutputElementRepresentation(prop1, prop2); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + { + if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null) + throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation."); + + if (activityOutputElementRepresentation.Prop1Option.IsSet) + writer.WriteString("prop1", activityOutputElementRepresentation.Prop1); + + if (activityOutputElementRepresentation.Prop2Option.IsSet) + { + writer.WritePropertyName("prop2"); + JsonSerializer.Serialize(writer, activityOutputElementRepresentation.Prop2, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs new file mode 100644 index 000000000000..dcc268fc3a8d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -0,0 +1,400 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// AdditionalPropertiesClass + /// + public partial class AdditionalPropertiesClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// anytype1 + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// mapOfMapProperty + /// mapProperty + /// mapWithUndeclaredPropertiesAnytype1 + /// mapWithUndeclaredPropertiesAnytype2 + /// mapWithUndeclaredPropertiesAnytype3 + /// mapWithUndeclaredPropertiesString + [JsonConstructor] + public AdditionalPropertiesClass(Option anytype1 = default, Option emptyMap = default, Option>> mapOfMapProperty = default, Option> mapProperty = default, Option mapWithUndeclaredPropertiesAnytype1 = default, Option mapWithUndeclaredPropertiesAnytype2 = default, Option> mapWithUndeclaredPropertiesAnytype3 = default, Option> mapWithUndeclaredPropertiesString = default) + { + Anytype1Option = anytype1; + EmptyMapOption = emptyMap; + MapOfMapPropertyOption = mapOfMapProperty; + MapPropertyOption = mapProperty; + MapWithUndeclaredPropertiesAnytype1Option = mapWithUndeclaredPropertiesAnytype1; + MapWithUndeclaredPropertiesAnytype2Option = mapWithUndeclaredPropertiesAnytype2; + MapWithUndeclaredPropertiesAnytype3Option = mapWithUndeclaredPropertiesAnytype3; + MapWithUndeclaredPropertiesStringOption = mapWithUndeclaredPropertiesString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Anytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Anytype1Option { get; private set; } + + /// + /// Gets or Sets Anytype1 + /// + [JsonPropertyName("anytype_1")] + public Object Anytype1 { get { return this.Anytype1Option; } set { this.Anytype1Option = new Option(value); } } + + /// + /// Used to track the state of EmptyMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmptyMapOption { get; private set; } + + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + /// + /// an object with no declared properties and no undeclared properties, hence it's an empty map. + [JsonPropertyName("empty_map")] + public Object EmptyMap { get { return this.EmptyMapOption; } set { this.EmptyMapOption = new Option(value); } } + + /// + /// Used to track the state of MapOfMapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapOfMapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapOfMapProperty + /// + [JsonPropertyName("map_of_map_property")] + public Dictionary> MapOfMapProperty { get { return this.MapOfMapPropertyOption; } set { this.MapOfMapPropertyOption = new Option>>(value); } } + + /// + /// Used to track the state of MapProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapPropertyOption { get; private set; } + + /// + /// Gets or Sets MapProperty + /// + [JsonPropertyName("map_property")] + public Dictionary MapProperty { get { return this.MapPropertyOption; } set { this.MapPropertyOption = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype1 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype1Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype1 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_1")] + public Object MapWithUndeclaredPropertiesAnytype1 { get { return this.MapWithUndeclaredPropertiesAnytype1Option; } set { this.MapWithUndeclaredPropertiesAnytype1Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype2 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MapWithUndeclaredPropertiesAnytype2Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype2 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_2")] + public Object MapWithUndeclaredPropertiesAnytype2 { get { return this.MapWithUndeclaredPropertiesAnytype2Option; } set { this.MapWithUndeclaredPropertiesAnytype2Option = new Option(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesAnytype3 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesAnytype3Option { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesAnytype3 + /// + [JsonPropertyName("map_with_undeclared_properties_anytype_3")] + public Dictionary MapWithUndeclaredPropertiesAnytype3 { get { return this.MapWithUndeclaredPropertiesAnytype3Option; } set { this.MapWithUndeclaredPropertiesAnytype3Option = new Option>(value); } } + + /// + /// Used to track the state of MapWithUndeclaredPropertiesString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapWithUndeclaredPropertiesStringOption { get; private set; } + + /// + /// Gets or Sets MapWithUndeclaredPropertiesString + /// + [JsonPropertyName("map_with_undeclared_properties_string")] + public Dictionary MapWithUndeclaredPropertiesString { get { return this.MapWithUndeclaredPropertiesStringOption; } set { this.MapWithUndeclaredPropertiesStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class AdditionalPropertiesClass {\n"); + sb.Append(" Anytype1: ").Append(Anytype1).Append("\n"); + sb.Append(" EmptyMap: ").Append(EmptyMap).Append("\n"); + sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n"); + sb.Append(" MapProperty: ").Append(MapProperty).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype1: ").Append(MapWithUndeclaredPropertiesAnytype1).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype2: ").Append(MapWithUndeclaredPropertiesAnytype2).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesAnytype3: ").Append(MapWithUndeclaredPropertiesAnytype3).Append("\n"); + sb.Append(" MapWithUndeclaredPropertiesString: ").Append(MapWithUndeclaredPropertiesString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AdditionalPropertiesClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option anytype1 = default; + Option emptyMap = default; + Option>> mapOfMapProperty = default; + Option> mapProperty = default; + Option mapWithUndeclaredPropertiesAnytype1 = default; + Option mapWithUndeclaredPropertiesAnytype2 = default; + Option> mapWithUndeclaredPropertiesAnytype3 = default; + Option> mapWithUndeclaredPropertiesString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "empty_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + emptyMap = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_of_map_property": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapOfMapProperty = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_property": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapProperty = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_1": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype1 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_2": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype2 = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_anytype_3": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesAnytype3 = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_with_undeclared_properties_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapWithUndeclaredPropertiesString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (emptyMap.IsSet && emptyMap.Value == null) + throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null) + throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapProperty.IsSet && mapProperty.Value == null) + throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass."); + + if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null) + throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass."); + + return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null) + throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass."); + + if (additionalPropertiesClass.Anytype1Option.IsSet) + if (additionalPropertiesClass.Anytype1Option.Value != null) + { + writer.WritePropertyName("anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.Anytype1, jsonSerializerOptions); + } + else + writer.WriteNull("anytype_1"); + if (additionalPropertiesClass.EmptyMapOption.IsSet) + { + writer.WritePropertyName("empty_map"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.EmptyMap, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet) + { + writer.WritePropertyName("map_of_map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapOfMapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapPropertyOption.IsSet) + { + writer.WritePropertyName("map_property"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapProperty, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_1"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_2"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_anytype_3"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3, jsonSerializerOptions); + } + if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet) + { + writer.WritePropertyName("map_with_undeclared_properties_string"); + JsonSerializer.Serialize(writer, additionalPropertiesClass.MapWithUndeclaredPropertiesString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs new file mode 100644 index 000000000000..29362b0ca361 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Animal.cs @@ -0,0 +1,221 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Animal + /// + public partial class Animal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// color (default to "red") + [JsonConstructor] + public Animal(Option color = default) + { + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Animal {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AnimalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option color = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "className"); + + if (discriminator != null && discriminator.Equals("Cat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + if (discriminator != null && discriminator.Equals("Dog")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Animal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); + + return new Animal(color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + { + if (animal is Cat cat){ + JsonSerializer.Serialize(writer, cat, jsonSerializerOptions); + return; + } + + if (animal is Dog dog){ + JsonSerializer.Serialize(writer, dog, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, animal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + { + if (animal.ColorOption.IsSet && animal.Color == null) + throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); + + writer.WriteString("className", animal.ClassName); + + if (animal.ColorOption.IsSet) + writer.WriteString("color", animal.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs new file mode 100644 index 000000000000..f63a202f3973 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -0,0 +1,230 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ApiResponse + /// + public partial class ApiResponse : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// message + /// type + [JsonConstructor] + public ApiResponse(Option code = default, Option message = default, Option type = default) + { + CodeOption = code; + MessageOption = message; + TypeOption = type; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public int? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Message + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MessageOption { get; private set; } + + /// + /// Gets or Sets Message + /// + [JsonPropertyName("message")] + public string Message { get { return this.MessageOption; } set { this.MessageOption = new Option(value); } } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + + /// + /// Gets or Sets Type + /// + [JsonPropertyName("type")] + public string Type { get { return this.TypeOption; } set { this.TypeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ApiResponse {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ApiResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option code = default; + Option message = default; + Option type = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "code": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + code = new Option(utf8JsonReader.GetInt32()); + break; + case "message": + message = new Option(utf8JsonReader.GetString()); + break; + case "type": + type = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse."); + + if (message.IsSet && message.Value == null) + throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse."); + + return new ApiResponse(code, message, type); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apiResponse, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + { + if (apiResponse.MessageOption.IsSet && apiResponse.Message == null) + throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse."); + + if (apiResponse.TypeOption.IsSet && apiResponse.Type == null) + throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse."); + + if (apiResponse.CodeOption.IsSet) + writer.WriteNumber("code", apiResponse.CodeOption.Value.Value); + + if (apiResponse.MessageOption.IsSet) + writer.WriteString("message", apiResponse.Message); + + if (apiResponse.TypeOption.IsSet) + writer.WriteString("type", apiResponse.Type); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs new file mode 100644 index 000000000000..87e58a000210 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Apple.cs @@ -0,0 +1,262 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Apple + /// + public partial class Apple : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// colorCode + /// cultivar + /// origin + [JsonConstructor] + public Apple(Option colorCode = default, Option cultivar = default, Option origin = default) + { + ColorCodeOption = colorCode; + CultivarOption = cultivar; + OriginOption = origin; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ColorCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorCodeOption { get; private set; } + + /// + /// Gets or Sets ColorCode + /// + [JsonPropertyName("color_code")] + public string ColorCode { get { return this.ColorCodeOption; } set { this.ColorCodeOption = new Option(value); } } + + /// + /// Used to track the state of Cultivar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CultivarOption { get; private set; } + + /// + /// Gets or Sets Cultivar + /// + [JsonPropertyName("cultivar")] + public string Cultivar { get { return this.CultivarOption; } set { this.CultivarOption = new Option(value); } } + + /// + /// Used to track the state of Origin + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OriginOption { get; private set; } + + /// + /// Gets or Sets Origin + /// + [JsonPropertyName("origin")] + public string Origin { get { return this.OriginOption; } set { this.OriginOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Apple {\n"); + sb.Append(" ColorCode: ").Append(ColorCode).Append("\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); + sb.Append(" Origin: ").Append(Origin).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + if (this.ColorCodeOption.Value != null) { + // ColorCode (string) pattern + Regex regexColorCode = new Regex(@"^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$", RegexOptions.CultureInvariant); + + if (this.ColorCodeOption.Value != null &&!regexColorCode.Match(this.ColorCodeOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ColorCode, must match a pattern of " + regexColorCode, new [] { "ColorCode" }); + } + } + + if (this.CultivarOption.Value != null) { + // Cultivar (string) pattern + Regex regexCultivar = new Regex(@"^[a-zA-Z\s]*$", RegexOptions.CultureInvariant); + + if (this.CultivarOption.Value != null &&!regexCultivar.Match(this.CultivarOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Cultivar, must match a pattern of " + regexCultivar, new [] { "Cultivar" }); + } + } + + if (this.OriginOption.Value != null) { + // Origin (string) pattern + Regex regexOrigin = new Regex(@"^[A-Z\s]*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.OriginOption.Value != null &&!regexOrigin.Match(this.OriginOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Origin, must match a pattern of " + regexOrigin, new [] { "Origin" }); + } + } + + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option colorCode = default; + Option cultivar = default; + Option origin = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color_code": + colorCode = new Option(utf8JsonReader.GetString()); + break; + case "cultivar": + cultivar = new Option(utf8JsonReader.GetString()); + break; + case "origin": + origin = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (colorCode.IsSet && colorCode.Value == null) + throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple."); + + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple."); + + if (origin.IsSet && origin.Value == null) + throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple."); + + return new Apple(colorCode, cultivar, origin); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, apple, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + { + if (apple.ColorCodeOption.IsSet && apple.ColorCode == null) + throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple."); + + if (apple.CultivarOption.IsSet && apple.Cultivar == null) + throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple."); + + if (apple.OriginOption.IsSet && apple.Origin == null) + throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple."); + + if (apple.ColorCodeOption.IsSet) + writer.WriteString("color_code", apple.ColorCode); + + if (apple.CultivarOption.IsSet) + writer.WriteString("cultivar", apple.Cultivar); + + if (apple.OriginOption.IsSet) + writer.WriteString("origin", apple.Origin); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs new file mode 100644 index 000000000000..6a2e8b75f6da --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// AppleReq + /// + public partial class AppleReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// cultivar + /// mealy + [JsonConstructor] + public AppleReq(string cultivar, Option mealy = default) + { + Cultivar = cultivar; + MealyOption = mealy; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Cultivar + /// + [JsonPropertyName("cultivar")] + public string Cultivar { get; set; } + + /// + /// Used to track the state of Mealy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MealyOption { get; private set; } + + /// + /// Gets or Sets Mealy + /// + [JsonPropertyName("mealy")] + public bool? Mealy { get { return this.MealyOption; } set { this.MealyOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class AppleReq {\n"); + sb.Append(" Cultivar: ").Append(Cultivar).Append("\n"); + sb.Append(" Mealy: ").Append(Mealy).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class AppleReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option cultivar = default; + Option mealy = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "cultivar": + cultivar = new Option(utf8JsonReader.GetString()); + break; + case "mealy": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mealy = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!cultivar.IsSet) + throw new ArgumentException("Property is required for class AppleReq.", nameof(cultivar)); + + if (cultivar.IsSet && cultivar.Value == null) + throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq."); + + if (mealy.IsSet && mealy.Value == null) + throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq."); + + return new AppleReq(cultivar.Value, mealy); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, appleReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + { + if (appleReq.Cultivar == null) + throw new ArgumentNullException(nameof(appleReq.Cultivar), "Property is required for class AppleReq."); + + writer.WriteString("cultivar", appleReq.Cultivar); + + if (appleReq.MealyOption.IsSet) + writer.WriteBoolean("mealy", appleReq.MealyOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs new file mode 100644 index 000000000000..d66d69222da8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayOfArrayOfNumberOnly + /// + public partial class ArrayOfArrayOfNumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayArrayNumber + [JsonConstructor] + public ArrayOfArrayOfNumberOnly(Option>> arrayArrayNumber = default) + { + ArrayArrayNumberOption = arrayArrayNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayNumberOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayNumber + /// + [JsonPropertyName("ArrayArrayNumber")] + public List> ArrayArrayNumber { get { return this.ArrayArrayNumberOption; } set { this.ArrayArrayNumberOption = new Option>>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayOfArrayOfNumberOnly {\n"); + sb.Append(" ArrayArrayNumber: ").Append(ArrayArrayNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayOfArrayOfNumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> arrayArrayNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ArrayArrayNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayNumber = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly."); + + return new ArrayOfArrayOfNumberOnly(arrayArrayNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly."); + + if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfArrayOfNumberOnly.ArrayArrayNumber, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs new file mode 100644 index 000000000000..7ec6a05f2420 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayOfNumberOnly + /// + public partial class ArrayOfNumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayNumber + [JsonConstructor] + public ArrayOfNumberOnly(Option> arrayNumber = default) + { + ArrayNumberOption = arrayNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNumberOption { get; private set; } + + /// + /// Gets or Sets ArrayNumber + /// + [JsonPropertyName("ArrayNumber")] + public List ArrayNumber { get { return this.ArrayNumberOption; } set { this.ArrayNumberOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayOfNumberOnly {\n"); + sb.Append(" ArrayNumber: ").Append(ArrayNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayOfNumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ArrayNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayNumber = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayNumber.IsSet && arrayNumber.Value == null) + throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly."); + + return new ArrayOfNumberOnly(arrayNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null) + throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly."); + + if (arrayOfNumberOnly.ArrayNumberOption.IsSet) + { + writer.WritePropertyName("ArrayNumber"); + JsonSerializer.Serialize(writer, arrayOfNumberOnly.ArrayNumber, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs new file mode 100644 index 000000000000..0ae28dc07d59 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -0,0 +1,242 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ArrayTest + /// + public partial class ArrayTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayArrayOfInteger + /// arrayArrayOfModel + /// arrayOfString + [JsonConstructor] + public ArrayTest(Option>> arrayArrayOfInteger = default, Option>> arrayArrayOfModel = default, Option> arrayOfString = default) + { + ArrayArrayOfIntegerOption = arrayArrayOfInteger; + ArrayArrayOfModelOption = arrayArrayOfModel; + ArrayOfStringOption = arrayOfString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayArrayOfInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfIntegerOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayOfInteger + /// + [JsonPropertyName("array_array_of_integer")] + public List> ArrayArrayOfInteger { get { return this.ArrayArrayOfIntegerOption; } set { this.ArrayArrayOfIntegerOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayArrayOfModel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> ArrayArrayOfModelOption { get; private set; } + + /// + /// Gets or Sets ArrayArrayOfModel + /// + [JsonPropertyName("array_array_of_model")] + public List> ArrayArrayOfModel { get { return this.ArrayArrayOfModelOption; } set { this.ArrayArrayOfModelOption = new Option>>(value); } } + + /// + /// Used to track the state of ArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets ArrayOfString + /// + [JsonPropertyName("array_of_string")] + public List ArrayOfString { get { return this.ArrayOfStringOption; } set { this.ArrayOfStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ArrayTest {\n"); + sb.Append(" ArrayArrayOfInteger: ").Append(ArrayArrayOfInteger).Append("\n"); + sb.Append(" ArrayArrayOfModel: ").Append(ArrayArrayOfModel).Append("\n"); + sb.Append(" ArrayOfString: ").Append(ArrayOfString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ArrayTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> arrayArrayOfInteger = default; + Option>> arrayArrayOfModel = default; + Option> arrayOfString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_array_of_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayOfInteger = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_array_of_model": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayArrayOfModel = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest."); + + if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null) + throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest."); + + if (arrayOfString.IsSet && arrayOfString.Value == null) + throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest."); + + return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, arrayTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + { + if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null) + throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest."); + + if (arrayTest.ArrayArrayOfIntegerOption.IsSet) + { + writer.WritePropertyName("array_array_of_integer"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfInteger, jsonSerializerOptions); + } + if (arrayTest.ArrayArrayOfModelOption.IsSet) + { + writer.WritePropertyName("array_array_of_model"); + JsonSerializer.Serialize(writer, arrayTest.ArrayArrayOfModel, jsonSerializerOptions); + } + if (arrayTest.ArrayOfStringOption.IsSet) + { + writer.WritePropertyName("array_of_string"); + JsonSerializer.Serialize(writer, arrayTest.ArrayOfString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs new file mode 100644 index 000000000000..f8f25778428e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Banana.cs @@ -0,0 +1,172 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Banana + /// + public partial class Banana : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lengthCm + [JsonConstructor] + public Banana(Option lengthCm = default) + { + LengthCmOption = lengthCm; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of LengthCm + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LengthCmOption { get; private set; } + + /// + /// Gets or Sets LengthCm + /// + [JsonPropertyName("lengthCm")] + public decimal? LengthCm { get { return this.LengthCmOption; } set { this.LengthCmOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Banana {\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option lengthCm = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lengthCm": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + lengthCm = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana."); + + return new Banana(lengthCm); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, banana, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + { + if (banana.LengthCmOption.IsSet) + writer.WriteNumber("lengthCm", banana.LengthCmOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs new file mode 100644 index 000000000000..848e8164b4ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs @@ -0,0 +1,187 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// BananaReq + /// + public partial class BananaReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lengthCm + /// sweet + [JsonConstructor] + public BananaReq(decimal lengthCm, Option sweet = default) + { + LengthCm = lengthCm; + SweetOption = sweet; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets LengthCm + /// + [JsonPropertyName("lengthCm")] + public decimal LengthCm { get; set; } + + /// + /// Used to track the state of Sweet + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SweetOption { get; private set; } + + /// + /// Gets or Sets Sweet + /// + [JsonPropertyName("sweet")] + public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class BananaReq {\n"); + sb.Append(" LengthCm: ").Append(LengthCm).Append("\n"); + sb.Append(" Sweet: ").Append(Sweet).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BananaReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option lengthCm = default; + Option sweet = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lengthCm": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + lengthCm = new Option(utf8JsonReader.GetDecimal()); + break; + case "sweet": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + sweet = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!lengthCm.IsSet) + throw new ArgumentException("Property is required for class BananaReq.", nameof(lengthCm)); + + if (lengthCm.IsSet && lengthCm.Value == null) + throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq."); + + if (sweet.IsSet && sweet.Value == null) + throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq."); + + return new BananaReq(lengthCm.Value.Value, sweet); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, bananaReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteNumber("lengthCm", bananaReq.LengthCm); + + if (bananaReq.SweetOption.IsSet) + writer.WriteBoolean("sweet", bananaReq.SweetOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs new file mode 100644 index 000000000000..863cc82bc782 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// BasquePig + /// + public partial class BasquePig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + [JsonConstructor] + public BasquePig(string className) + { + ClassName = className; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class BasquePig {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class BasquePigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override BasquePig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class BasquePig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class BasquePig."); + + return new BasquePig(className.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, basquePig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + { + if (basquePig.ClassName == null) + throw new ArgumentNullException(nameof(basquePig.ClassName), "Property is required for class BasquePig."); + + writer.WriteString("className", basquePig.ClassName); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs new file mode 100644 index 000000000000..f24497e3ad68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs @@ -0,0 +1,320 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Capitalization + /// + public partial class Capitalization : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Name of the pet + /// capitalCamel + /// capitalSnake + /// sCAETHFlowPoints + /// smallCamel + /// smallSnake + [JsonConstructor] + public Capitalization(Option aTTNAME = default, Option capitalCamel = default, Option capitalSnake = default, Option sCAETHFlowPoints = default, Option smallCamel = default, Option smallSnake = default) + { + ATT_NAMEOption = aTTNAME; + CapitalCamelOption = capitalCamel; + CapitalSnakeOption = capitalSnake; + SCAETHFlowPointsOption = sCAETHFlowPoints; + SmallCamelOption = smallCamel; + SmallSnakeOption = smallSnake; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ATT_NAME + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ATT_NAMEOption { get; private set; } + + /// + /// Name of the pet + /// + /// Name of the pet + [JsonPropertyName("ATT_NAME")] + public string ATT_NAME { get { return this.ATT_NAMEOption; } set { this.ATT_NAMEOption = new Option(value); } } + + /// + /// Used to track the state of CapitalCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalCamelOption { get; private set; } + + /// + /// Gets or Sets CapitalCamel + /// + [JsonPropertyName("CapitalCamel")] + public string CapitalCamel { get { return this.CapitalCamelOption; } set { this.CapitalCamelOption = new Option(value); } } + + /// + /// Used to track the state of CapitalSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CapitalSnakeOption { get; private set; } + + /// + /// Gets or Sets CapitalSnake + /// + [JsonPropertyName("Capital_Snake")] + public string CapitalSnake { get { return this.CapitalSnakeOption; } set { this.CapitalSnakeOption = new Option(value); } } + + /// + /// Used to track the state of SCAETHFlowPoints + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SCAETHFlowPointsOption { get; private set; } + + /// + /// Gets or Sets SCAETHFlowPoints + /// + [JsonPropertyName("SCA_ETH_Flow_Points")] + public string SCAETHFlowPoints { get { return this.SCAETHFlowPointsOption; } set { this.SCAETHFlowPointsOption = new Option(value); } } + + /// + /// Used to track the state of SmallCamel + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallCamelOption { get; private set; } + + /// + /// Gets or Sets SmallCamel + /// + [JsonPropertyName("smallCamel")] + public string SmallCamel { get { return this.SmallCamelOption; } set { this.SmallCamelOption = new Option(value); } } + + /// + /// Used to track the state of SmallSnake + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SmallSnakeOption { get; private set; } + + /// + /// Gets or Sets SmallSnake + /// + [JsonPropertyName("small_Snake")] + public string SmallSnake { get { return this.SmallSnakeOption; } set { this.SmallSnakeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Capitalization {\n"); + sb.Append(" ATT_NAME: ").Append(ATT_NAME).Append("\n"); + sb.Append(" CapitalCamel: ").Append(CapitalCamel).Append("\n"); + sb.Append(" CapitalSnake: ").Append(CapitalSnake).Append("\n"); + sb.Append(" SCAETHFlowPoints: ").Append(SCAETHFlowPoints).Append("\n"); + sb.Append(" SmallCamel: ").Append(SmallCamel).Append("\n"); + sb.Append(" SmallSnake: ").Append(SmallSnake).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class CapitalizationJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option aTTNAME = default; + Option capitalCamel = default; + Option capitalSnake = default; + Option sCAETHFlowPoints = default; + Option smallCamel = default; + Option smallSnake = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ATT_NAME": + aTTNAME = new Option(utf8JsonReader.GetString()); + break; + case "CapitalCamel": + capitalCamel = new Option(utf8JsonReader.GetString()); + break; + case "Capital_Snake": + capitalSnake = new Option(utf8JsonReader.GetString()); + break; + case "SCA_ETH_Flow_Points": + sCAETHFlowPoints = new Option(utf8JsonReader.GetString()); + break; + case "smallCamel": + smallCamel = new Option(utf8JsonReader.GetString()); + break; + case "small_Snake": + smallSnake = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (aTTNAME.IsSet && aTTNAME.Value == null) + throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization."); + + if (capitalCamel.IsSet && capitalCamel.Value == null) + throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization."); + + if (capitalSnake.IsSet && capitalSnake.Value == null) + throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization."); + + if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null) + throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization."); + + if (smallCamel.IsSet && smallCamel.Value == null) + throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization."); + + if (smallSnake.IsSet && smallSnake.Value == null) + throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization."); + + return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, capitalization, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + { + if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null) + throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization."); + + if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null) + throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization."); + + if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null) + throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization."); + + if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null) + throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization."); + + if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null) + throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization."); + + if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null) + throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization."); + + if (capitalization.ATT_NAMEOption.IsSet) + writer.WriteString("ATT_NAME", capitalization.ATT_NAME); + + if (capitalization.CapitalCamelOption.IsSet) + writer.WriteString("CapitalCamel", capitalization.CapitalCamel); + + if (capitalization.CapitalSnakeOption.IsSet) + writer.WriteString("Capital_Snake", capitalization.CapitalSnake); + + if (capitalization.SCAETHFlowPointsOption.IsSet) + writer.WriteString("SCA_ETH_Flow_Points", capitalization.SCAETHFlowPoints); + + if (capitalization.SmallCamelOption.IsSet) + writer.WriteString("smallCamel", capitalization.SmallCamel); + + if (capitalization.SmallSnakeOption.IsSet) + writer.WriteString("small_Snake", capitalization.SmallSnake); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs new file mode 100644 index 000000000000..d11d16c855e0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Cat.cs @@ -0,0 +1,189 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Cat + /// + public partial class Cat : Animal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// color (default to "red") + /// declawed + [JsonConstructor] + public Cat(Option color = default, Option declawed = default) : base(color) + { + DeclawedOption = declawed; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string ClassName { get; } = "Cat"; + + /// + /// Used to track the state of Declawed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeclawedOption { get; private set; } + + /// + /// Gets or Sets Declawed + /// + [JsonPropertyName("declawed")] + public bool? Declawed { get { return this.DeclawedOption; } set { this.DeclawedOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Cat {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CatJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option color = default; + Option declawed = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + case "declawed": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + declawed = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Cat.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat."); + + if (declawed.IsSet && declawed.Value == null) + throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); + + return new Cat(color, declawed); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, cat, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + { + if (cat.ColorOption.IsSet && cat.Color == null) + throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); + + writer.WriteString("className", cat.ClassName); + + if (cat.ColorOption.IsSet) + writer.WriteString("color", cat.Color); + + if (cat.DeclawedOption.IsSet) + writer.WriteBoolean("declawed", cat.DeclawedOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs new file mode 100644 index 000000000000..667e094c6ff4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Category.cs @@ -0,0 +1,196 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Category + /// + public partial class Category : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + /// name (default to "default-name") + [JsonConstructor] + public Category(Option id = default, string name = @"default-name") + { + IdOption = id; + Name = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class CategoryJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option id = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!name.IsSet) + throw new ArgumentException("Property is required for class Category.", nameof(name)); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category."); + + return new Category(id, name.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, category, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + { + if (category.Name == null) + throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category."); + + if (category.IdOption.IsSet) + writer.WriteNumber("id", category.IdOption.Value.Value); + + writer.WriteString("name", category.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs new file mode 100644 index 000000000000..a27854474976 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs @@ -0,0 +1,231 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ChildCat + /// + public partial class ChildCat : ParentPet, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public ChildCat(Option name = default) : base() + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines PetType + /// + public enum PetTypeEnum + { + /// + /// Enum ChildCat for value: ChildCat + /// + ChildCat = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static PetTypeEnum PetTypeEnumFromString(string value) + { + if (value.Equals("ChildCat")) + return PetTypeEnum.ChildCat; + + throw new NotImplementedException($"Could not convert value to type PetTypeEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static PetTypeEnum? PetTypeEnumFromStringOrDefault(string value) + { + if (value.Equals("ChildCat")) + return PetTypeEnum.ChildCat; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string PetTypeEnumToJsonValue(PetTypeEnum value) + { + if (value == PetTypeEnum.ChildCat) + return "ChildCat"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new PetTypeEnum PetType { get; } = (PetTypeEnum)Enum.Parse(typeof(PetTypeEnum), "ChildCat"); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ChildCat {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class ChildCatJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + Option petType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + case "pet_type": + string petTypeRawValue = utf8JsonReader.GetString(); + if (petTypeRawValue != null) + petType = new Option(ChildCat.PetTypeEnumFromStringOrDefault(petTypeRawValue)); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ChildCat.", nameof(petType)); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); + + return new ChildCat(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, childCat, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + { + if (childCat.NameOption.IsSet && childCat.Name == null) + throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat."); + + if (childCat.NameOption.IsSet) + writer.WriteString("name", childCat.Name); + + writer.WriteString("pet_type", ChildCat.PetTypeEnumToJsonValue(childCat.PetType)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs new file mode 100644 index 000000000000..9e254109cfcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model with \"_class\" property + /// + public partial class ClassModel : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// class + [JsonConstructor] + public ClassModel(Option @class = default) + { + ClassOption = @class; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Class + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ClassOption { get; private set; } + + /// + /// Gets or Sets Class + /// + [JsonPropertyName("_class")] + public string Class { get { return this.ClassOption; } set { this.ClassOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ClassModel {\n"); + sb.Append(" Class: ").Append(Class).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ClassModelJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClass = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "_class": + varClass = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel."); + + return new ClassModel(varClass); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, classModel, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + { + if (classModel.ClassOption.IsSet && classModel.Class == null) + throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel."); + + if (classModel.ClassOption.IsSet) + writer.WriteString("_class", classModel.Class); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs new file mode 100644 index 000000000000..1a42f967ca91 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ComplexQuadrilateral + /// + public partial class ComplexQuadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + /// shapeType + [JsonConstructor] + public ComplexQuadrilateral(string quadrilateralType, string shapeType) + { + QuadrilateralType = quadrilateralType; + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ComplexQuadrilateral {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ComplexQuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ComplexQuadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(quadrilateralType)); + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ComplexQuadrilateral.", nameof(shapeType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class ComplexQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ComplexQuadrilateral."); + + return new ComplexQuadrilateral(quadrilateralType.Value, shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + if (complexQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.QuadrilateralType), "Property is required for class ComplexQuadrilateral."); + + if (complexQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(complexQuadrilateral.ShapeType), "Property is required for class ComplexQuadrilateral."); + + writer.WriteString("quadrilateralType", complexQuadrilateral.QuadrilateralType); + + writer.WriteString("shapeType", complexQuadrilateral.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs new file mode 100644 index 000000000000..9eb8b733358d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DanishPig + /// + public partial class DanishPig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + [JsonConstructor] + public DanishPig(string className) + { + ClassName = className; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DanishPig {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DanishPigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DanishPig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class DanishPig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class DanishPig."); + + return new DanishPig(className.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, danishPig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + { + if (danishPig.ClassName == null) + throw new ArgumentNullException(nameof(danishPig.ClassName), "Property is required for class DanishPig."); + + writer.WriteString("className", danishPig.ClassName); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..c82942faae75 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + public partial class DateOnlyClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty + [JsonConstructor] + public DateOnlyClass(Option dateOnlyProperty = default) + { + DateOnlyPropertyOption = dateOnlyProperty; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of DateOnlyProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateOnlyPropertyOption { get; private set; } + + /// + /// Gets or Sets DateOnlyProperty + /// + /// Fri Jul 21 00:00:00 UTC 2017 + [JsonPropertyName("dateOnlyProperty")] + public DateTime? DateOnlyProperty { get { return this.DateOnlyPropertyOption; } set { this.DateOnlyPropertyOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DateOnlyClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateOnlyProperty + /// + public static string DateOnlyPropertyFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option dateOnlyProperty = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "dateOnlyProperty": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateOnlyProperty = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null) + throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass."); + + return new DateOnlyClass(dateOnlyProperty); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + if (dateOnlyClass.DateOnlyPropertyOption.IsSet) + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value.Value.ToString(DateOnlyPropertyFormat)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs new file mode 100644 index 000000000000..064985cce436 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// DeprecatedObject + /// + public partial class DeprecatedObject : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public DeprecatedObject(Option name = default) + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DeprecatedObject {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DeprecatedObjectJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject."); + + return new DeprecatedObject(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + { + if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null) + throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject."); + + if (deprecatedObject.NameOption.IsSet) + writer.WriteString("name", deprecatedObject.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs new file mode 100644 index 000000000000..75a60416f90c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Dog.cs @@ -0,0 +1,191 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Dog + /// + public partial class Dog : Animal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// breed + /// color (default to "red") + [JsonConstructor] + public Dog(Option breed = default, Option color = default) : base(color) + { + BreedOption = breed; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string ClassName { get; } = "Dog"; + + /// + /// Used to track the state of Breed + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BreedOption { get; private set; } + + /// + /// Gets or Sets Breed + /// + [JsonPropertyName("breed")] + public string Breed { get { return this.BreedOption; } set { this.BreedOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Dog {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class DogJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option breed = default; + Option color = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "breed": + breed = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Dog.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog."); + + if (breed.IsSet && breed.Value == null) + throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); + + return new Dog(breed, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, dog, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + { + if (dog.BreedOption.IsSet && dog.Breed == null) + throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); + + if (dog.ColorOption.IsSet && dog.Color == null) + throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog."); + + writer.WriteString("className", dog.ClassName); + + if (dog.BreedOption.IsSet) + writer.WriteString("breed", dog.Breed); + + if (dog.ColorOption.IsSet) + writer.WriteString("color", dog.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs new file mode 100644 index 000000000000..13fe9ec2c1a5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -0,0 +1,268 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Drawing + /// + public partial class Drawing : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// mainShape + /// nullableShape + /// shapeOrNull + /// shapes + [JsonConstructor] + public Drawing(Option mainShape = default, Option nullableShape = default, Option shapeOrNull = default, Option> shapes = default) + { + MainShapeOption = mainShape; + NullableShapeOption = nullableShape; + ShapeOrNullOption = shapeOrNull; + ShapesOption = shapes; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of MainShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MainShapeOption { get; private set; } + + /// + /// Gets or Sets MainShape + /// + [JsonPropertyName("mainShape")] + public Shape MainShape { get { return this.MainShapeOption; } set { this.MainShapeOption = new Option(value); } } + + /// + /// Used to track the state of NullableShape + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableShapeOption { get; private set; } + + /// + /// Gets or Sets NullableShape + /// + [JsonPropertyName("nullableShape")] + public NullableShape NullableShape { get { return this.NullableShapeOption; } set { this.NullableShapeOption = new Option(value); } } + + /// + /// Used to track the state of ShapeOrNull + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShapeOrNullOption { get; private set; } + + /// + /// Gets or Sets ShapeOrNull + /// + [JsonPropertyName("shapeOrNull")] + public ShapeOrNull ShapeOrNull { get { return this.ShapeOrNullOption; } set { this.ShapeOrNullOption = new Option(value); } } + + /// + /// Used to track the state of Shapes + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ShapesOption { get; private set; } + + /// + /// Gets or Sets Shapes + /// + [JsonPropertyName("shapes")] + public List Shapes { get { return this.ShapesOption; } set { this.ShapesOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Drawing {\n"); + sb.Append(" MainShape: ").Append(MainShape).Append("\n"); + sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); + sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class DrawingJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option mainShape = default; + Option nullableShape = default; + Option shapeOrNull = default; + Option> shapes = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "mainShape": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mainShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "nullableShape": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + nullableShape = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapeOrNull": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapeOrNull = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "shapes": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shapes = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (mainShape.IsSet && mainShape.Value == null) + throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing."); + + if (shapes.IsSet && shapes.Value == null) + throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing."); + + return new Drawing(mainShape, nullableShape, shapeOrNull, shapes); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, drawing, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + { + if (drawing.MainShapeOption.IsSet && drawing.MainShape == null) + throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing."); + + if (drawing.ShapesOption.IsSet && drawing.Shapes == null) + throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing."); + + if (drawing.MainShapeOption.IsSet) + { + writer.WritePropertyName("mainShape"); + JsonSerializer.Serialize(writer, drawing.MainShape, jsonSerializerOptions); + } + if (drawing.NullableShapeOption.IsSet) + if (drawing.NullableShapeOption.Value != null) + { + writer.WritePropertyName("nullableShape"); + JsonSerializer.Serialize(writer, drawing.NullableShape, jsonSerializerOptions); + } + else + writer.WriteNull("nullableShape"); + if (drawing.ShapeOrNullOption.IsSet) + if (drawing.ShapeOrNullOption.Value != null) + { + writer.WritePropertyName("shapeOrNull"); + JsonSerializer.Serialize(writer, drawing.ShapeOrNull, jsonSerializerOptions); + } + else + writer.WriteNull("shapeOrNull"); + if (drawing.ShapesOption.IsSet) + { + writer.WritePropertyName("shapes"); + JsonSerializer.Serialize(writer, drawing.Shapes, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs new file mode 100644 index 000000000000..a0b7504e9d2e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -0,0 +1,337 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EnumArrays + /// + public partial class EnumArrays : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayEnum + /// justSymbol + [JsonConstructor] + public EnumArrays(Option> arrayEnum = default, Option justSymbol = default) + { + ArrayEnumOption = arrayEnum; + JustSymbolOption = justSymbol; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines ArrayEnum + /// + public enum ArrayEnumEnum + { + /// + /// Enum Fish for value: fish + /// + Fish = 1, + + /// + /// Enum Crab for value: crab + /// + Crab = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static ArrayEnumEnum ArrayEnumEnumFromString(string value) + { + if (value.Equals("fish")) + return ArrayEnumEnum.Fish; + + if (value.Equals("crab")) + return ArrayEnumEnum.Crab; + + throw new NotImplementedException($"Could not convert value to type ArrayEnumEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static ArrayEnumEnum? ArrayEnumEnumFromStringOrDefault(string value) + { + if (value.Equals("fish")) + return ArrayEnumEnum.Fish; + + if (value.Equals("crab")) + return ArrayEnumEnum.Crab; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ArrayEnumEnumToJsonValue(ArrayEnumEnum value) + { + if (value == ArrayEnumEnum.Fish) + return "fish"; + + if (value == ArrayEnumEnum.Crab) + return "crab"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Defines JustSymbol + /// + public enum JustSymbolEnum + { + /// + /// Enum GreaterThanOrEqualTo for value: >= + /// + GreaterThanOrEqualTo = 1, + + /// + /// Enum Dollar for value: $ + /// + Dollar = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static JustSymbolEnum JustSymbolEnumFromString(string value) + { + if (value.Equals(">=")) + return JustSymbolEnum.GreaterThanOrEqualTo; + + if (value.Equals("$")) + return JustSymbolEnum.Dollar; + + throw new NotImplementedException($"Could not convert value to type JustSymbolEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static JustSymbolEnum? JustSymbolEnumFromStringOrDefault(string value) + { + if (value.Equals(">=")) + return JustSymbolEnum.GreaterThanOrEqualTo; + + if (value.Equals("$")) + return JustSymbolEnum.Dollar; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string JustSymbolEnumToJsonValue(JustSymbolEnum? value) + { + if (value == JustSymbolEnum.GreaterThanOrEqualTo) + return ">="; + + if (value == JustSymbolEnum.Dollar) + return "$"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of JustSymbol + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustSymbolOption { get; private set; } + + /// + /// Gets or Sets JustSymbol + /// + [JsonPropertyName("just_symbol")] + public JustSymbolEnum? JustSymbol { get { return this.JustSymbolOption; } set { this.JustSymbolOption = new Option(value); } } + + /// + /// Used to track the state of ArrayEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayEnumOption { get; private set; } + + /// + /// Gets or Sets ArrayEnum + /// + [JsonPropertyName("array_enum")] + public List ArrayEnum { get { return this.ArrayEnumOption; } set { this.ArrayEnumOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EnumArrays {\n"); + sb.Append(" ArrayEnum: ").Append(ArrayEnum).Append("\n"); + sb.Append(" JustSymbol: ").Append(JustSymbol).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EnumArraysJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayEnum = default; + Option justSymbol = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_enum": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayEnum = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "just_symbol": + string justSymbolRawValue = utf8JsonReader.GetString(); + if (justSymbolRawValue != null) + justSymbol = new Option(EnumArrays.JustSymbolEnumFromStringOrDefault(justSymbolRawValue)); + break; + default: + break; + } + } + } + + if (arrayEnum.IsSet && arrayEnum.Value == null) + throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays."); + + if (justSymbol.IsSet && justSymbol.Value == null) + throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays."); + + return new EnumArrays(arrayEnum, justSymbol); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, enumArrays, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + { + if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null) + throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays."); + + if (enumArrays.ArrayEnumOption.IsSet) + { + writer.WritePropertyName("array_enum"); + JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions); + } + var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value.Value); + writer.WriteString("just_symbol", justSymbolRawValue); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumClass.cs new file mode 100644 index 000000000000..b1aff0adf0d8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumClass.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines EnumClass + /// + public enum EnumClass + { + /// + /// Enum Abc for value: _abc + /// + Abc = 1, + + /// + /// Enum Efg for value: -efg + /// + Efg = 2, + + /// + /// Enum Xyz for value: (xyz) + /// + Xyz = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class EnumClassValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static EnumClass FromString(string value) + { + if (value.Equals("_abc")) + return EnumClass.Abc; + + if (value.Equals("-efg")) + return EnumClass.Efg; + + if (value.Equals("(xyz)")) + return EnumClass.Xyz; + + throw new NotImplementedException($"Could not convert value to type EnumClass: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static EnumClass? FromStringOrDefault(string value) + { + if (value.Equals("_abc")) + return EnumClass.Abc; + + if (value.Equals("-efg")) + return EnumClass.Efg; + + if (value.Equals("(xyz)")) + return EnumClass.Xyz; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(EnumClass value) + { + if (value == EnumClass.Abc) + return "_abc"; + + if (value == EnumClass.Efg) + return "-efg"; + + if (value == EnumClass.Xyz) + return "(xyz)"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class EnumClassJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override EnumClass Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumClass? result = rawValue == null + ? null + : EnumClassValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the EnumClass to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumClass enumClass, JsonSerializerOptions options) + { + writer.WriteStringValue(enumClass.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class EnumClassNullableJsonConverter : JsonConverter + { + /// + /// Returns a EnumClass from the Json object + /// + /// + /// + /// + /// + public override EnumClass? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + EnumClass? result = rawValue == null + ? null + : EnumClassValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumClass? enumClass, JsonSerializerOptions options) + { + writer.WriteStringValue(enumClass?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs new file mode 100644 index 000000000000..dc39f92290d6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs @@ -0,0 +1,881 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EnumTest + /// + public partial class EnumTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// enumStringRequired + /// enumInteger + /// enumIntegerOnly + /// enumNumber + /// enumString + /// outerEnum + /// outerEnumDefaultValue + /// outerEnumInteger + /// outerEnumIntegerDefaultValue + [JsonConstructor] + public EnumTest(EnumStringRequiredEnum enumStringRequired, Option enumInteger = default, Option enumIntegerOnly = default, Option enumNumber = default, Option enumString = default, Option outerEnum = default, Option outerEnumDefaultValue = default, Option outerEnumInteger = default, Option outerEnumIntegerDefaultValue = default) + { + EnumStringRequired = enumStringRequired; + EnumIntegerOption = enumInteger; + EnumIntegerOnlyOption = enumIntegerOnly; + EnumNumberOption = enumNumber; + EnumStringOption = enumString; + OuterEnumOption = outerEnum; + OuterEnumDefaultValueOption = outerEnumDefaultValue; + OuterEnumIntegerOption = outerEnumInteger; + OuterEnumIntegerDefaultValueOption = outerEnumIntegerDefaultValue; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines EnumStringRequired + /// + public enum EnumStringRequiredEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringRequiredEnum EnumStringRequiredEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringRequiredEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringRequiredEnum.Lower; + + if (value.Equals("")) + return EnumStringRequiredEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringRequiredEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringRequiredEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringRequiredEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringRequiredEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringRequiredEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringRequiredEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringRequiredEnum? EnumStringRequiredEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringRequiredEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringRequiredEnum.Lower; + + if (value.Equals("")) + return EnumStringRequiredEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringRequiredEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringRequiredEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringRequiredEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringRequiredEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringRequiredEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringRequiredEnumToJsonValue(EnumStringRequiredEnum value) + { + if (value == EnumStringRequiredEnum.UPPER) + return "UPPER"; + + if (value == EnumStringRequiredEnum.Lower) + return "lower"; + + if (value == EnumStringRequiredEnum.Empty) + return ""; + + if (value == EnumStringRequiredEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringRequiredEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringRequiredEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringRequiredEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringRequiredEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets EnumStringRequired + /// + [JsonPropertyName("enum_string_required")] + public EnumStringRequiredEnum EnumStringRequired { get; set; } + + /// + /// Defines EnumInteger + /// + public enum EnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerEnum EnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerEnum? EnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return EnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return EnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerEnumToJsonValue(EnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOption { get; private set; } + + /// + /// Gets or Sets EnumInteger + /// + [JsonPropertyName("enum_integer")] + public EnumIntegerEnum? EnumInteger { get { return this.EnumIntegerOption; } set { this.EnumIntegerOption = new Option(value); } } + + /// + /// Defines EnumIntegerOnly + /// + public enum EnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumIntegerOnlyEnum EnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type EnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumIntegerOnlyEnum? EnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return EnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int EnumIntegerOnlyEnumToJsonValue(EnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of EnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets EnumIntegerOnly + /// + [JsonPropertyName("enum_integer_only")] + public EnumIntegerOnlyEnum? EnumIntegerOnly { get { return this.EnumIntegerOnlyOption; } set { this.EnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines EnumNumber + /// + public enum EnumNumberEnum + { + /// + /// Enum NUMBER_1_DOT_1 for value: 1.1 + /// + NUMBER_1_DOT_1 = 1, + + /// + /// Enum NUMBER_MINUS_1_DOT_2 for value: -1.2 + /// + NUMBER_MINUS_1_DOT_2 = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumNumberEnum EnumNumberEnumFromString(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + throw new NotImplementedException($"Could not convert value to type EnumNumberEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumNumberEnum? EnumNumberEnumFromStringOrDefault(string value) + { + if (value.Equals("1.1")) + return EnumNumberEnum.NUMBER_1_DOT_1; + + if (value.Equals("-1.2")) + return EnumNumberEnum.NUMBER_MINUS_1_DOT_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static double EnumNumberEnumToJsonValue(EnumNumberEnum? value) + { + if (value == EnumNumberEnum.NUMBER_1_DOT_1) + return 1.1; + + if (value == EnumNumberEnum.NUMBER_MINUS_1_DOT_2) + return -1.2; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumNumberOption { get; private set; } + + /// + /// Gets or Sets EnumNumber + /// + [JsonPropertyName("enum_number")] + public EnumNumberEnum? EnumNumber { get { return this.EnumNumberOption; } set { this.EnumNumberOption = new Option(value); } } + + /// + /// Defines EnumString + /// + public enum EnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static EnumStringEnum EnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type EnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static EnumStringEnum? EnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return EnumStringEnum.UPPER; + + if (value.Equals("lower")) + return EnumStringEnum.Lower; + + if (value.Equals("")) + return EnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return EnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return EnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return EnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return EnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return EnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string EnumStringEnumToJsonValue(EnumStringEnum? value) + { + if (value == EnumStringEnum.UPPER) + return "UPPER"; + + if (value == EnumStringEnum.Lower) + return "lower"; + + if (value == EnumStringEnum.Empty) + return ""; + + if (value == EnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == EnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == EnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == EnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == EnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of EnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EnumStringOption { get; private set; } + + /// + /// Gets or Sets EnumString + /// + [JsonPropertyName("enum_string")] + public EnumStringEnum? EnumString { get { return this.EnumStringOption; } set { this.EnumStringOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumOption { get; private set; } + + /// + /// Gets or Sets OuterEnum + /// + [JsonPropertyName("outerEnum")] + public OuterEnum? OuterEnum { get { return this.OuterEnumOption; } set { this.OuterEnumOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumDefaultValue + /// + [JsonPropertyName("outerEnumDefaultValue")] + public OuterEnumDefaultValue? OuterEnumDefaultValue { get { return this.OuterEnumDefaultValueOption; } set { this.OuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets OuterEnumInteger + /// + [JsonPropertyName("outerEnumInteger")] + public OuterEnumInteger? OuterEnumInteger { get { return this.OuterEnumIntegerOption; } set { this.OuterEnumIntegerOption = new Option(value); } } + + /// + /// Used to track the state of OuterEnumIntegerDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OuterEnumIntegerDefaultValueOption { get; private set; } + + /// + /// Gets or Sets OuterEnumIntegerDefaultValue + /// + [JsonPropertyName("outerEnumIntegerDefaultValue")] + public OuterEnumIntegerDefaultValue? OuterEnumIntegerDefaultValue { get { return this.OuterEnumIntegerDefaultValueOption; } set { this.OuterEnumIntegerDefaultValueOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EnumTest {\n"); + sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n"); + sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n"); + sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n"); + sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n"); + sb.Append(" EnumString: ").Append(EnumString).Append("\n"); + sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n"); + sb.Append(" OuterEnumDefaultValue: ").Append(OuterEnumDefaultValue).Append("\n"); + sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n"); + sb.Append(" OuterEnumIntegerDefaultValue: ").Append(OuterEnumIntegerDefaultValue).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EnumTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option enumStringRequired = default; + Option enumInteger = default; + Option enumIntegerOnly = default; + Option enumNumber = default; + Option enumString = default; + Option outerEnum = default; + Option outerEnumDefaultValue = default; + Option outerEnumInteger = default; + Option outerEnumIntegerDefaultValue = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "enum_string_required": + string enumStringRequiredRawValue = utf8JsonReader.GetString(); + if (enumStringRequiredRawValue != null) + enumStringRequired = new Option(EnumTest.EnumStringRequiredEnumFromStringOrDefault(enumStringRequiredRawValue)); + break; + case "enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + enumInteger = new Option((EnumTest.EnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + enumIntegerOnly = new Option((EnumTest.EnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "enum_number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + enumNumber = new Option((EnumTest.EnumNumberEnum)utf8JsonReader.GetInt32()); + break; + case "enum_string": + string enumStringRawValue = utf8JsonReader.GetString(); + if (enumStringRawValue != null) + enumString = new Option(EnumTest.EnumStringEnumFromStringOrDefault(enumStringRawValue)); + break; + case "outerEnum": + string outerEnumRawValue = utf8JsonReader.GetString(); + if (outerEnumRawValue != null) + outerEnum = new Option(OuterEnumValueConverter.FromStringOrDefault(outerEnumRawValue)); + break; + case "outerEnumDefaultValue": + string outerEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumDefaultValueRawValue != null) + outerEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(outerEnumDefaultValueRawValue)); + break; + case "outerEnumInteger": + string outerEnumIntegerRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerRawValue != null) + outerEnumInteger = new Option(OuterEnumIntegerValueConverter.FromStringOrDefault(outerEnumIntegerRawValue)); + break; + case "outerEnumIntegerDefaultValue": + string outerEnumIntegerDefaultValueRawValue = utf8JsonReader.GetString(); + if (outerEnumIntegerDefaultValueRawValue != null) + outerEnumIntegerDefaultValue = new Option(OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(outerEnumIntegerDefaultValueRawValue)); + break; + default: + break; + } + } + } + + if (!enumStringRequired.IsSet) + throw new ArgumentException("Property is required for class EnumTest.", nameof(enumStringRequired)); + + if (enumStringRequired.IsSet && enumStringRequired.Value == null) + throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest."); + + if (enumInteger.IsSet && enumInteger.Value == null) + throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest."); + + if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest."); + + if (enumNumber.IsSet && enumNumber.Value == null) + throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest."); + + if (enumString.IsSet && enumString.Value == null) + throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest."); + + if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest."); + + if (outerEnumInteger.IsSet && outerEnumInteger.Value == null) + throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest."); + + if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null) + throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest."); + + return new EnumTest(enumStringRequired.Value.Value, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, enumTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + { + var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); + writer.WriteString("enum_string_required", enumStringRequiredRawValue); + if (enumTest.EnumIntegerOption.IsSet) + writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value.Value)); + + if (enumTest.EnumIntegerOnlyOption.IsSet) + writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value.Value)); + + if (enumTest.EnumNumberOption.IsSet) + writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value.Value)); + + var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value.Value); + writer.WriteString("enum_string", enumStringRawValue); + if (enumTest.OuterEnumOption.IsSet) + if (enumTest.OuterEnumOption.Value != null) + { + var outerEnumRawValue = OuterEnumValueConverter.ToJsonValue(enumTest.OuterEnumOption.Value.Value); + writer.WriteString("outerEnum", outerEnumRawValue); + } + else + writer.WriteNull("outerEnum"); + if (enumTest.OuterEnumDefaultValueOption.IsSet) + { + var outerEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumDefaultValue.Value); + writer.WriteString("outerEnumDefaultValue", outerEnumDefaultValueRawValue); + } + if (enumTest.OuterEnumIntegerOption.IsSet) + { + var outerEnumIntegerRawValue = OuterEnumIntegerValueConverter.ToJsonValue(enumTest.OuterEnumInteger.Value); + writer.WriteNumber("outerEnumInteger", outerEnumIntegerRawValue); + } + if (enumTest.OuterEnumIntegerDefaultValueOption.IsSet) + { + var outerEnumIntegerDefaultValueRawValue = OuterEnumIntegerDefaultValueValueConverter.ToJsonValue(enumTest.OuterEnumIntegerDefaultValue.Value); + writer.WriteNumber("outerEnumIntegerDefaultValue", outerEnumIntegerDefaultValueRawValue); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs new file mode 100644 index 000000000000..b84f89b531dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EquilateralTriangle + /// + public partial class EquilateralTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public EquilateralTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EquilateralTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EquilateralTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EquilateralTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class EquilateralTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class EquilateralTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class EquilateralTriangle."); + + return new EquilateralTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (equilateralTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.ShapeType), "Property is required for class EquilateralTriangle."); + + if (equilateralTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(equilateralTriangle.TriangleType), "Property is required for class EquilateralTriangle."); + + writer.WriteString("shapeType", equilateralTriangle.ShapeType); + + writer.WriteString("triangleType", equilateralTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs new file mode 100644 index 000000000000..95403fdaf96d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/File.cs @@ -0,0 +1,175 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Must be named `File` for test. + /// + public partial class File : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Test capitalization + [JsonConstructor] + public File(Option sourceURI = default) + { + SourceURIOption = sourceURI; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of SourceURI + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SourceURIOption { get; private set; } + + /// + /// Test capitalization + /// + /// Test capitalization + [JsonPropertyName("sourceURI")] + public string SourceURI { get { return this.SourceURIOption; } set { this.SourceURIOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class File {\n"); + sb.Append(" SourceURI: ").Append(SourceURI).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FileJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option sourceURI = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "sourceURI": + sourceURI = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (sourceURI.IsSet && sourceURI.Value == null) + throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File."); + + return new File(sourceURI); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, file, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + { + if (file.SourceURIOption.IsSet && file.SourceURI == null) + throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File."); + + if (file.SourceURIOption.IsSet) + writer.WriteString("sourceURI", file.SourceURI); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs new file mode 100644 index 000000000000..4906accc7ed4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -0,0 +1,210 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FileSchemaTestClass + /// + public partial class FileSchemaTestClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// file + /// files + [JsonConstructor] + public FileSchemaTestClass(Option file = default, Option> files = default) + { + FileOption = file; + FilesOption = files; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of File + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FileOption { get; private set; } + + /// + /// Gets or Sets File + /// + [JsonPropertyName("file")] + public File File { get { return this.FileOption; } set { this.FileOption = new Option(value); } } + + /// + /// Used to track the state of Files + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> FilesOption { get; private set; } + + /// + /// Gets or Sets Files + /// + [JsonPropertyName("files")] + public List Files { get { return this.FilesOption; } set { this.FilesOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FileSchemaTestClass {\n"); + sb.Append(" File: ").Append(File).Append("\n"); + sb.Append(" Files: ").Append(Files).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FileSchemaTestClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option file = default; + Option> files = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "file": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + file = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "files": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + files = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (file.IsSet && file.Value == null) + throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass."); + + if (files.IsSet && files.Value == null) + throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass."); + + return new FileSchemaTestClass(file, files); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + { + if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null) + throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass."); + + if (fileSchemaTestClass.FileOption.IsSet) + { + writer.WritePropertyName("file"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.File, jsonSerializerOptions); + } + if (fileSchemaTestClass.FilesOption.IsSet) + { + writer.WritePropertyName("files"); + JsonSerializer.Serialize(writer, fileSchemaTestClass.Files, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs new file mode 100644 index 000000000000..a78d7a84f34f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Foo.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Foo + /// + public partial class Foo : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar (default to "bar") + [JsonConstructor] + public Foo(Option bar = default) + { + BarOption = bar; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; private set; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } set { this.BarOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Foo {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FooJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo."); + + return new Foo(bar); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, foo, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + { + if (foo.BarOption.IsSet && foo.Bar == null) + throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo."); + + if (foo.BarOption.IsSet) + writer.WriteString("bar", foo.Bar); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs new file mode 100644 index 000000000000..4564148c4d9c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FooGetDefaultResponse + /// + public partial class FooGetDefaultResponse : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// string + [JsonConstructor] + public FooGetDefaultResponse(Option @string = default) + { + StringOption = @string; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + [JsonPropertyName("string")] + public Foo String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FooGetDefaultResponse {\n"); + sb.Append(" String: ").Append(String).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FooGetDefaultResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varString = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse."); + + return new FooGetDefaultResponse(varString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + { + if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null) + throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse."); + + if (fooGetDefaultResponse.StringOption.IsSet) + { + writer.WritePropertyName("string"); + JsonSerializer.Serialize(writer, fooGetDefaultResponse.String, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs new file mode 100644 index 000000000000..09b13bde9f7a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs @@ -0,0 +1,798 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FormatTest + /// + public partial class FormatTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// byte + /// date + /// number + /// password + /// binary + /// dateTime + /// decimal + /// double + /// float + /// int32 + /// int64 + /// integer + /// None + /// A string that is a 10 digit number. Can have leading zeros. + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + /// string + /// unsignedInteger + /// unsignedLong + /// uuid + [JsonConstructor] + public FormatTest(byte[] @byte, DateTime date, decimal number, string password, Option binary = default, Option dateTime = default, Option @decimal = default, Option @double = default, Option @float = default, Option int32 = default, Option int64 = default, Option integer = default, Option patternWithBackslash = default, Option patternWithDigits = default, Option patternWithDigitsAndDelimiter = default, Option @string = default, Option unsignedInteger = default, Option unsignedLong = default, Option uuid = default) + { + Byte = @byte; + Date = date; + Number = number; + Password = password; + BinaryOption = binary; + DateTimeOption = dateTime; + DecimalOption = @decimal; + DoubleOption = @double; + FloatOption = @float; + Int32Option = int32; + Int64Option = int64; + IntegerOption = integer; + PatternWithBackslashOption = patternWithBackslash; + PatternWithDigitsOption = patternWithDigits; + PatternWithDigitsAndDelimiterOption = patternWithDigitsAndDelimiter; + StringOption = @string; + UnsignedIntegerOption = unsignedInteger; + UnsignedLongOption = unsignedLong; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Byte + /// + [JsonPropertyName("byte")] + public byte[] Byte { get; set; } + + /// + /// Gets or Sets Date + /// + /// Sun Feb 02 00:00:00 UTC 2020 + [JsonPropertyName("date")] + public DateTime Date { get; set; } + + /// + /// Gets or Sets Number + /// + [JsonPropertyName("number")] + public decimal Number { get; set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get; set; } + + /// + /// Used to track the state of Binary + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BinaryOption { get; private set; } + + /// + /// Gets or Sets Binary + /// + [JsonPropertyName("binary")] + public System.IO.Stream Binary { get { return this.BinaryOption; } set { this.BinaryOption = new Option(value); } } + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + /// 2007-12-03T10:15:30+01:00 + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this.DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + [JsonPropertyName("decimal")] + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of Double + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DoubleOption { get; private set; } + + /// + /// Gets or Sets Double + /// + [JsonPropertyName("double")] + public double? Double { get { return this.DoubleOption; } set { this.DoubleOption = new Option(value); } } + + /// + /// Used to track the state of Float + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FloatOption { get; private set; } + + /// + /// Gets or Sets Float + /// + [JsonPropertyName("float")] + public float? Float { get { return this.FloatOption; } set { this.FloatOption = new Option(value); } } + + /// + /// Used to track the state of Int32 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int32Option { get; private set; } + + /// + /// Gets or Sets Int32 + /// + [JsonPropertyName("int32")] + public int? Int32 { get { return this.Int32Option; } set { this.Int32Option = new Option(value); } } + + /// + /// Used to track the state of Int64 + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Int64Option { get; private set; } + + /// + /// Gets or Sets Int64 + /// + [JsonPropertyName("int64")] + public long? Int64 { get { return this.Int64Option; } set { this.Int64Option = new Option(value); } } + + /// + /// Used to track the state of Integer + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerOption { get; private set; } + + /// + /// Gets or Sets Integer + /// + [JsonPropertyName("integer")] + public int? Integer { get { return this.IntegerOption; } set { this.IntegerOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithBackslash + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithBackslashOption { get; private set; } + + /// + /// None + /// + /// None + [JsonPropertyName("pattern_with_backslash")] + public string PatternWithBackslash { get { return this.PatternWithBackslashOption; } set { this.PatternWithBackslashOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigits + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsOption { get; private set; } + + /// + /// A string that is a 10 digit number. Can have leading zeros. + /// + /// A string that is a 10 digit number. Can have leading zeros. + [JsonPropertyName("pattern_with_digits")] + public string PatternWithDigits { get { return this.PatternWithDigitsOption; } set { this.PatternWithDigitsOption = new Option(value); } } + + /// + /// Used to track the state of PatternWithDigitsAndDelimiter + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PatternWithDigitsAndDelimiterOption { get; private set; } + + /// + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + /// + /// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + [JsonPropertyName("pattern_with_digits_and_delimiter")] + public string PatternWithDigitsAndDelimiter { get { return this.PatternWithDigitsAndDelimiterOption; } set { this.PatternWithDigitsAndDelimiterOption = new Option(value); } } + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + [JsonPropertyName("string")] + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedIntegerOption { get; private set; } + + /// + /// Gets or Sets UnsignedInteger + /// + [JsonPropertyName("unsigned_integer")] + public uint? UnsignedInteger { get { return this.UnsignedIntegerOption; } set { this.UnsignedIntegerOption = new Option(value); } } + + /// + /// Used to track the state of UnsignedLong + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsignedLongOption { get; private set; } + + /// + /// Gets or Sets UnsignedLong + /// + [JsonPropertyName("unsigned_long")] + public ulong? UnsignedLong { get { return this.UnsignedLongOption; } set { this.UnsignedLongOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FormatTest {\n"); + sb.Append(" Byte: ").Append(Byte).Append("\n"); + sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Decimal: ").Append(Decimal).Append("\n"); + sb.Append(" Double: ").Append(Double).Append("\n"); + sb.Append(" Float: ").Append(Float).Append("\n"); + sb.Append(" Int32: ").Append(Int32).Append("\n"); + sb.Append(" Int64: ").Append(Int64).Append("\n"); + sb.Append(" Integer: ").Append(Integer).Append("\n"); + sb.Append(" PatternWithBackslash: ").Append(PatternWithBackslash).Append("\n"); + sb.Append(" PatternWithDigits: ").Append(PatternWithDigits).Append("\n"); + sb.Append(" PatternWithDigitsAndDelimiter: ").Append(PatternWithDigitsAndDelimiter).Append("\n"); + sb.Append(" String: ").Append(String).Append("\n"); + sb.Append(" UnsignedInteger: ").Append(UnsignedInteger).Append("\n"); + sb.Append(" UnsignedLong: ").Append(UnsignedLong).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + // Number (decimal) maximum + if (this.Number > (decimal)543.2) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value less than or equal to 543.2.", new [] { "Number" }); + } + + // Number (decimal) minimum + if (this.Number < (decimal)32.1) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" }); + } + + // Password (string) maxLength + if (this.Password != null && this.Password.Length > 64) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be less than 64.", new [] { "Password" }); + } + + // Password (string) minLength + if (this.Password != null && this.Password.Length < 10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" }); + } + + // Double (double) maximum + if (this.DoubleOption.IsSet && this.DoubleOption.Value > (double)123.4) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value less than or equal to 123.4.", new [] { "Double" }); + } + + // Double (double) minimum + if (this.DoubleOption.IsSet && this.DoubleOption.Value < (double)67.8) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value greater than or equal to 67.8.", new [] { "Double" }); + } + + // Float (float) maximum + if (this.FloatOption.IsSet && this.FloatOption.Value > (float)987.6) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value less than or equal to 987.6.", new [] { "Float" }); + } + + // Float (float) minimum + if (this.FloatOption.IsSet && this.FloatOption.Value < (float)54.3) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value greater than or equal to 54.3.", new [] { "Float" }); + } + + // Int32 (int) maximum + if (this.Int32Option.IsSet && this.Int32Option.Value > (int)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" }); + } + + // Int32 (int) minimum + if (this.Int32Option.IsSet && this.Int32Option.Value < (int)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" }); + } + + // Integer (int) maximum + if (this.IntegerOption.IsSet && this.IntegerOption.Value > (int)100) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" }); + } + + // Integer (int) minimum + if (this.IntegerOption.IsSet && this.IntegerOption.Value < (int)10) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" }); + } + + if (this.PatternWithBackslashOption.Value != null) { + // PatternWithBackslash (string) pattern + Regex regexPatternWithBackslash = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$", RegexOptions.CultureInvariant); + + if (this.PatternWithBackslashOption.Value != null &&!regexPatternWithBackslash.Match(this.PatternWithBackslashOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithBackslash, must match a pattern of " + regexPatternWithBackslash, new [] { "PatternWithBackslash" }); + } + } + + if (this.PatternWithDigitsOption.Value != null) { + // PatternWithDigits (string) pattern + Regex regexPatternWithDigits = new Regex(@"^\d{10}$", RegexOptions.CultureInvariant); + + if (this.PatternWithDigitsOption.Value != null &&!regexPatternWithDigits.Match(this.PatternWithDigitsOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigits, must match a pattern of " + regexPatternWithDigits, new [] { "PatternWithDigits" }); + } + } + + if (this.PatternWithDigitsAndDelimiterOption.Value != null) { + // PatternWithDigitsAndDelimiter (string) pattern + Regex regexPatternWithDigitsAndDelimiter = new Regex(@"^image_\d{1,3}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.PatternWithDigitsAndDelimiterOption.Value != null &&!regexPatternWithDigitsAndDelimiter.Match(this.PatternWithDigitsAndDelimiterOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PatternWithDigitsAndDelimiter, must match a pattern of " + regexPatternWithDigitsAndDelimiter, new [] { "PatternWithDigitsAndDelimiter" }); + } + } + + if (this.StringOption.Value != null) { + // String (string) pattern + Regex regexString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); + + if (this.StringOption.Value != null &&!regexString.Match(this.StringOption.Value).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for String, must match a pattern of " + regexString, new [] { "String" }); + } + } + + // UnsignedInteger (uint) maximum + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value > (uint)200) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value less than or equal to 200.", new [] { "UnsignedInteger" }); + } + + // UnsignedInteger (uint) minimum + if (this.UnsignedIntegerOption.IsSet && this.UnsignedIntegerOption.Value < (uint)20) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UnsignedInteger, must be a value greater than or equal to 20.", new [] { "UnsignedInteger" }); + } + + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FormatTestJsonConverter : JsonConverter + { + /// + /// The format to use to serialize Date + /// + public static string DateFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize DateTime + /// + public static string DateTimeFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varByte = default; + Option date = default; + Option number = default; + Option password = default; + Option binary = default; + Option dateTime = default; + Option varDecimal = default; + Option varDouble = default; + Option varFloat = default; + Option int32 = default; + Option int64 = default; + Option integer = default; + Option patternWithBackslash = default; + Option patternWithDigits = default; + Option patternWithDigitsAndDelimiter = default; + Option varString = default; + Option unsignedInteger = default; + Option unsignedLong = default; + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "byte": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varByte = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "date": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + date = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + number = new Option(utf8JsonReader.GetDecimal()); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "binary": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + binary = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "decimal": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDecimal = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "double": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varDouble = new Option(utf8JsonReader.GetDouble()); + break; + case "float": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varFloat = new Option((float)utf8JsonReader.GetDouble()); + break; + case "int32": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int32 = new Option(utf8JsonReader.GetInt32()); + break; + case "int64": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + int64 = new Option(utf8JsonReader.GetInt64()); + break; + case "integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integer = new Option(utf8JsonReader.GetInt32()); + break; + case "pattern_with_backslash": + patternWithBackslash = new Option(utf8JsonReader.GetString()); + break; + case "pattern_with_digits": + patternWithDigits = new Option(utf8JsonReader.GetString()); + break; + case "pattern_with_digits_and_delimiter": + patternWithDigitsAndDelimiter = new Option(utf8JsonReader.GetString()); + break; + case "string": + varString = new Option(utf8JsonReader.GetString()); + break; + case "unsigned_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + unsignedInteger = new Option(utf8JsonReader.GetUInt32()); + break; + case "unsigned_long": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + unsignedLong = new Option(utf8JsonReader.GetUInt64()); + break; + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!varByte.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(varByte)); + + if (!date.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(date)); + + if (!number.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(number)); + + if (!password.IsSet) + throw new ArgumentException("Property is required for class FormatTest.", nameof(password)); + + if (varByte.IsSet && varByte.Value == null) + throw new ArgumentNullException(nameof(varByte), "Property is not nullable for class FormatTest."); + + if (date.IsSet && date.Value == null) + throw new ArgumentNullException(nameof(date), "Property is not nullable for class FormatTest."); + + if (number.IsSet && number.Value == null) + throw new ArgumentNullException(nameof(number), "Property is not nullable for class FormatTest."); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class FormatTest."); + + if (binary.IsSet && binary.Value == null) + throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest."); + + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest."); + + if (varDecimal.IsSet && varDecimal.Value == null) + throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest."); + + if (varDouble.IsSet && varDouble.Value == null) + throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest."); + + if (varFloat.IsSet && varFloat.Value == null) + throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest."); + + if (int32.IsSet && int32.Value == null) + throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest."); + + if (int64.IsSet && int64.Value == null) + throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest."); + + if (integer.IsSet && integer.Value == null) + throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest."); + + if (patternWithBackslash.IsSet && patternWithBackslash.Value == null) + throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest."); + + if (patternWithDigits.IsSet && patternWithDigits.Value == null) + throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest."); + + if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null) + throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest."); + + if (varString.IsSet && varString.Value == null) + throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest."); + + if (unsignedInteger.IsSet && unsignedInteger.Value == null) + throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest."); + + if (unsignedLong.IsSet && unsignedLong.Value == null) + throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest."); + + return new FormatTest(varByte.Value, date.Value.Value, number.Value.Value, password.Value, binary, dateTime, varDecimal, varDouble, varFloat, int32, int64, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, unsignedInteger, unsignedLong, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, formatTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + { + if (formatTest.Byte == null) + throw new ArgumentNullException(nameof(formatTest.Byte), "Property is required for class FormatTest."); + + if (formatTest.Password == null) + throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest."); + + if (formatTest.BinaryOption.IsSet && formatTest.Binary == null) + throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest."); + + if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest."); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null) + throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest."); + + if (formatTest.StringOption.IsSet && formatTest.String == null) + throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest."); + + writer.WritePropertyName("byte"); + JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions); + writer.WriteString("date", formatTest.Date.ToString(DateFormat)); + + writer.WriteNumber("number", formatTest.Number); + + writer.WriteString("password", formatTest.Password); + + if (formatTest.BinaryOption.IsSet) + { + writer.WritePropertyName("binary"); + JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); + } + if (formatTest.DateTimeOption.IsSet) + writer.WriteString("dateTime", formatTest.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (formatTest.DecimalOption.IsSet) + { + writer.WritePropertyName("decimal"); + JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions); + } + if (formatTest.DoubleOption.IsSet) + writer.WriteNumber("double", formatTest.DoubleOption.Value.Value); + + if (formatTest.FloatOption.IsSet) + writer.WriteNumber("float", formatTest.FloatOption.Value.Value); + + if (formatTest.Int32Option.IsSet) + writer.WriteNumber("int32", formatTest.Int32Option.Value.Value); + + if (formatTest.Int64Option.IsSet) + writer.WriteNumber("int64", formatTest.Int64Option.Value.Value); + + if (formatTest.IntegerOption.IsSet) + writer.WriteNumber("integer", formatTest.IntegerOption.Value.Value); + + if (formatTest.PatternWithBackslashOption.IsSet) + writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash); + + if (formatTest.PatternWithDigitsOption.IsSet) + writer.WriteString("pattern_with_digits", formatTest.PatternWithDigits); + + if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet) + writer.WriteString("pattern_with_digits_and_delimiter", formatTest.PatternWithDigitsAndDelimiter); + + if (formatTest.StringOption.IsSet) + writer.WriteString("string", formatTest.String); + + if (formatTest.UnsignedIntegerOption.IsSet) + writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value.Value); + + if (formatTest.UnsignedLongOption.IsSet) + writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value.Value); + + if (formatTest.UuidOption.IsSet) + writer.WriteString("uuid", formatTest.UuidOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs new file mode 100644 index 000000000000..8e650b7b07cc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Fruit.cs @@ -0,0 +1,218 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Fruit + /// + public partial class Fruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Apple apple, Option color = default) + { + Apple = apple; + ColorOption = color; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// color + public Fruit(Banana banana, Option color = default) + { + Banana = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get; set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get; set; } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Fruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit."); + + if (apple != null) + return new Fruit(apple, color); + + if (banana != null) + return new Fruit(banana, color); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + { + if (fruit.ColorOption.IsSet && fruit.Color == null) + throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit."); + + if (fruit.ColorOption.IsSet) + writer.WriteString("color", fruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs new file mode 100644 index 000000000000..f5dd6d56278f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// FruitReq + /// + public partial class FruitReq : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public FruitReq(AppleReq appleReq) + { + AppleReq = appleReq; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public FruitReq(BananaReq bananaReq) + { + BananaReq = bananaReq; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets AppleReq + /// + public AppleReq AppleReq { get; set; } + + /// + /// Gets or Sets BananaReq + /// + public BananaReq BananaReq { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class FruitReq {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class FruitReqJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override FruitReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + AppleReq appleReq = default; + BananaReq bananaReq = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderAppleReq = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderAppleReq, jsonSerializerOptions, out appleReq); + + Utf8JsonReader utf8JsonReaderBananaReq = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBananaReq, jsonSerializerOptions, out bananaReq); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (appleReq != null) + return new FruitReq(appleReq); + + if (bananaReq != null) + return new FruitReq(bananaReq); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, fruitReq, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs new file mode 100644 index 000000000000..14d47fa32935 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs @@ -0,0 +1,235 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// GmFruit + /// + public partial class GmFruit : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// color + public GmFruit(Option apple, Option banana, Option color = default) + { + AppleOption = apple; + BananaOption = banana; + ColorOption = color; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Apple + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AppleOption { get; private set; } + + /// + /// Gets or Sets Apple + /// + public Apple Apple { get { return this.AppleOption; } set { this.AppleOption = new Option(value); } } + + /// + /// Used to track the state of Banana + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BananaOption { get; private set; } + + /// + /// Gets or Sets Banana + /// + public Banana Banana { get { return this.BananaOption; } set { this.BananaOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Gets or Sets Color + /// + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class GmFruit {\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class GmFruitJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option color = default; + + Apple apple = default; + Banana banana = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderApple = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderApple, jsonSerializerOptions, out apple); + + Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit."); + + Option appleParsedValue = apple == null + ? default + : new Option(apple); + Option bananaParsedValue = banana == null + ? default + : new Option(banana); + + return new GmFruit(appleParsedValue, bananaParsedValue, color); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) + { + AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); + AppleJsonConverter.WriteProperties(writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + } + + if (gmFruit.BananaOption.IsSet && gmFruit.BananaOption.Value != null) + { + BananaJsonConverter BananaJsonConverter = (BananaJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.BananaOption.Value.GetType())); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, gmFruit, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + { + if (gmFruit.ColorOption.IsSet && gmFruit.Color == null) + throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit."); + + if (gmFruit.ColorOption.IsSet) + writer.WriteString("color", gmFruit.Color); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs new file mode 100644 index 000000000000..86246ae54570 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -0,0 +1,192 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// GrandparentAnimal + /// + public partial class GrandparentAnimal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public GrandparentAnimal() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class GrandparentAnimal {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class GrandparentAnimalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option petType = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type"); + + if (discriminator != null && discriminator.Equals("ChildCat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + if (discriminator != null && discriminator.Equals("ParentPet")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "pet_type": + petType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class GrandparentAnimal.", nameof(petType)); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); + + return new GrandparentAnimal(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + { + if (grandparentAnimal is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + + if (grandparentAnimal is ParentPet parentPet){ + JsonSerializer.Serialize(writer, parentPet, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("pet_type", grandparentAnimal.PetType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs new file mode 100644 index 000000000000..88c5d4274eab --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -0,0 +1,244 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// HasOnlyReadOnly + /// + public partial class HasOnlyReadOnly : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar + /// foo + [JsonConstructor] + internal HasOnlyReadOnly(Option bar = default, Option foo = default) + { + BarOption = bar; + FooOption = foo; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } } + + /// + /// Used to track the state of Foo + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FooOption { get; } + + /// + /// Gets or Sets Foo + /// + [JsonPropertyName("foo")] + public string Foo { get { return this.FooOption; } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class HasOnlyReadOnly {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Foo: ").Append(Foo).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as HasOnlyReadOnly).AreEqual; + } + + /// + /// Returns true if HasOnlyReadOnly instances are equal + /// + /// Instance of HasOnlyReadOnly to be compared + /// Boolean + public bool Equals(HasOnlyReadOnly input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + if (Foo != null) + hashCode = (hashCode * 59) + Foo.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class HasOnlyReadOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + Option foo = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + case "foo": + foo = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly."); + + if (foo.IsSet && foo.Value == null) + throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly."); + + return new HasOnlyReadOnly(bar, foo); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null) + throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly."); + + if (hasOnlyReadOnly.BarOption.IsSet) + writer.WriteString("bar", hasOnlyReadOnly.Bar); + + if (hasOnlyReadOnly.FooOption.IsSet) + writer.WriteString("foo", hasOnlyReadOnly.Foo); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs new file mode 100644 index 000000000000..4f9c831edc26 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -0,0 +1,171 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + /// + public partial class HealthCheckResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// nullableMessage + [JsonConstructor] + public HealthCheckResult(Option nullableMessage = default) + { + NullableMessageOption = nullableMessage; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of NullableMessage + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NullableMessageOption { get; private set; } + + /// + /// Gets or Sets NullableMessage + /// + [JsonPropertyName("NullableMessage")] + public string NullableMessage { get { return this.NullableMessageOption; } set { this.NullableMessageOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class HealthCheckResult {\n"); + sb.Append(" NullableMessage: ").Append(NullableMessage).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class HealthCheckResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override HealthCheckResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option nullableMessage = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "NullableMessage": + nullableMessage = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + return new HealthCheckResult(nullableMessage); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + { + if (healthCheckResult.NullableMessageOption.IsSet) + if (healthCheckResult.NullableMessageOption.Value != null) + writer.WriteString("NullableMessage", healthCheckResult.NullableMessage); + else + writer.WriteNull("NullableMessage"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs new file mode 100644 index 000000000000..384e48f3a155 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -0,0 +1,186 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// IsoscelesTriangle + /// + public partial class IsoscelesTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public IsoscelesTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class IsoscelesTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class IsoscelesTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override IsoscelesTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class IsoscelesTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class IsoscelesTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class IsoscelesTriangle."); + + return new IsoscelesTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (isoscelesTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.ShapeType), "Property is required for class IsoscelesTriangle."); + + if (isoscelesTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(isoscelesTriangle.TriangleType), "Property is required for class IsoscelesTriangle."); + + writer.WriteString("shapeType", isoscelesTriangle.ShapeType); + + writer.WriteString("triangleType", isoscelesTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs new file mode 100644 index 000000000000..07fcd017a689 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/List.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// List + /// + public partial class List : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// var123List + [JsonConstructor] + public List(Option var123List = default) + { + Var123ListOption = var123List; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Var123List + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123ListOption { get; private set; } + + /// + /// Gets or Sets Var123List + /// + [JsonPropertyName("123-list")] + public string Var123List { get { return this.Var123ListOption; } set { this.Var123ListOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class List {\n"); + sb.Append(" Var123List: ").Append(Var123List).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ListJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option var123List = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "123-list": + var123List = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (var123List.IsSet && var123List.Value == null) + throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List."); + + return new List(var123List); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, list, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + { + if (list.Var123ListOption.IsSet && list.Var123List == null) + throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List."); + + if (list.Var123ListOption.IsSet) + writer.WriteString("123-list", list.Var123List); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs new file mode 100644 index 000000000000..c5fc2e2e77c1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -0,0 +1,203 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// LiteralStringClass + /// + public partial class LiteralStringClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// escapedLiteralString (default to "C:\\Users\\username") + /// unescapedLiteralString (default to "C:\Users\username") + [JsonConstructor] + public LiteralStringClass(Option escapedLiteralString = default, Option unescapedLiteralString = default) + { + EscapedLiteralStringOption = escapedLiteralString; + UnescapedLiteralStringOption = unescapedLiteralString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of EscapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EscapedLiteralStringOption { get; private set; } + + /// + /// Gets or Sets EscapedLiteralString + /// + [JsonPropertyName("escapedLiteralString")] + public string EscapedLiteralString { get { return this.EscapedLiteralStringOption; } set { this.EscapedLiteralStringOption = new Option(value); } } + + /// + /// Used to track the state of UnescapedLiteralString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnescapedLiteralStringOption { get; private set; } + + /// + /// Gets or Sets UnescapedLiteralString + /// + [JsonPropertyName("unescapedLiteralString")] + public string UnescapedLiteralString { get { return this.UnescapedLiteralStringOption; } set { this.UnescapedLiteralStringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class LiteralStringClass {\n"); + sb.Append(" EscapedLiteralString: ").Append(EscapedLiteralString).Append("\n"); + sb.Append(" UnescapedLiteralString: ").Append(UnescapedLiteralString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class LiteralStringClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option escapedLiteralString = default; + Option unescapedLiteralString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "escapedLiteralString": + escapedLiteralString = new Option(utf8JsonReader.GetString()); + break; + case "unescapedLiteralString": + unescapedLiteralString = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (escapedLiteralString.IsSet && escapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass."); + + if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null) + throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass."); + + return new LiteralStringClass(escapedLiteralString, unescapedLiteralString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, literalStringClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + { + if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null) + throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass."); + + if (literalStringClass.EscapedLiteralStringOption.IsSet) + writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString); + + if (literalStringClass.UnescapedLiteralStringOption.IsSet) + writer.WriteString("unescapedLiteralString", literalStringClass.UnescapedLiteralString); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs new file mode 100644 index 000000000000..1be5661d9936 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -0,0 +1,266 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mammal + /// + public partial class Mammal : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Whale whale) + { + Whale = whale; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Zebra zebra) + { + Zebra = zebra; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Mammal(Pig pig) + { + Pig = pig; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Whale + /// + public Whale Whale { get; set; } + + /// + /// Gets or Sets Zebra + /// + public Zebra Zebra { get; set; } + + /// + /// Gets or Sets Pig + /// + public Pig Pig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Mammal {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MammalJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + Pig pig = null; + Whale whale = null; + Zebra zebra = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("className")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Pig")) + { + Utf8JsonReader utf8JsonReaderPig = utf8JsonReader; + pig = JsonSerializer.Deserialize(ref utf8JsonReaderPig, jsonSerializerOptions); + } + if (discriminator.Equals("whale")) + { + Utf8JsonReader utf8JsonReaderWhale = utf8JsonReader; + whale = JsonSerializer.Deserialize(ref utf8JsonReaderWhale, jsonSerializerOptions); + } + if (discriminator.Equals("zebra")) + { + Utf8JsonReader utf8JsonReaderZebra = utf8JsonReader; + zebra = JsonSerializer.Deserialize(ref utf8JsonReaderZebra, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Mammal.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); + + if (pig != null) + return new Mammal(pig); + + if (whale != null) + return new Mammal(whale); + + if (zebra != null) + return new Mammal(zebra); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mammal.Whale != null) { + WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); + } + + if (mammal.Zebra != null) { + ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); + } + + if (mammal.Pig != null) { + PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); + } + + WriteProperties(writer, mammal, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs new file mode 100644 index 000000000000..6be561e42f14 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MapTest.cs @@ -0,0 +1,340 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MapTest + /// + public partial class MapTest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// directMap + /// indirectMap + /// mapMapOfString + /// mapOfEnumString + [JsonConstructor] + public MapTest(Option> directMap = default, Option> indirectMap = default, Option>> mapMapOfString = default, Option> mapOfEnumString = default) + { + DirectMapOption = directMap; + IndirectMapOption = indirectMap; + MapMapOfStringOption = mapMapOfString; + MapOfEnumStringOption = mapOfEnumString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Inner + /// + public enum InnerEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static InnerEnum InnerEnumFromString(string value) + { + if (value.Equals("UPPER")) + return InnerEnum.UPPER; + + if (value.Equals("lower")) + return InnerEnum.Lower; + + throw new NotImplementedException($"Could not convert value to type InnerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static InnerEnum? InnerEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return InnerEnum.UPPER; + + if (value.Equals("lower")) + return InnerEnum.Lower; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string InnerEnumToJsonValue(InnerEnum value) + { + if (value == InnerEnum.UPPER) + return "UPPER"; + + if (value == InnerEnum.Lower) + return "lower"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of DirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> DirectMapOption { get; private set; } + + /// + /// Gets or Sets DirectMap + /// + [JsonPropertyName("direct_map")] + public Dictionary DirectMap { get { return this.DirectMapOption; } set { this.DirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of IndirectMap + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> IndirectMapOption { get; private set; } + + /// + /// Gets or Sets IndirectMap + /// + [JsonPropertyName("indirect_map")] + public Dictionary IndirectMap { get { return this.IndirectMapOption; } set { this.IndirectMapOption = new Option>(value); } } + + /// + /// Used to track the state of MapMapOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option>> MapMapOfStringOption { get; private set; } + + /// + /// Gets or Sets MapMapOfString + /// + [JsonPropertyName("map_map_of_string")] + public Dictionary> MapMapOfString { get { return this.MapMapOfStringOption; } set { this.MapMapOfStringOption = new Option>>(value); } } + + /// + /// Used to track the state of MapOfEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOfEnumStringOption { get; private set; } + + /// + /// Gets or Sets MapOfEnumString + /// + [JsonPropertyName("map_of_enum_string")] + public Dictionary MapOfEnumString { get { return this.MapOfEnumStringOption; } set { this.MapOfEnumStringOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MapTest {\n"); + sb.Append(" DirectMap: ").Append(DirectMap).Append("\n"); + sb.Append(" IndirectMap: ").Append(IndirectMap).Append("\n"); + sb.Append(" MapMapOfString: ").Append(MapMapOfString).Append("\n"); + sb.Append(" MapOfEnumString: ").Append(MapOfEnumString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MapTestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> directMap = default; + Option> indirectMap = default; + Option>> mapMapOfString = default; + Option> mapOfEnumString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "direct_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + directMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "indirect_map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + indirectMap = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_map_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapMapOfString = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map_of_enum_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mapOfEnumString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (directMap.IsSet && directMap.Value == null) + throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest."); + + if (indirectMap.IsSet && indirectMap.Value == null) + throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest."); + + if (mapMapOfString.IsSet && mapMapOfString.Value == null) + throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest."); + + if (mapOfEnumString.IsSet && mapOfEnumString.Value == null) + throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest."); + + return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mapTest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + { + if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null) + throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest."); + + if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null) + throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest."); + + if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null) + throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest."); + + if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null) + throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest."); + + if (mapTest.DirectMapOption.IsSet) + { + writer.WritePropertyName("direct_map"); + JsonSerializer.Serialize(writer, mapTest.DirectMap, jsonSerializerOptions); + } + if (mapTest.IndirectMapOption.IsSet) + { + writer.WritePropertyName("indirect_map"); + JsonSerializer.Serialize(writer, mapTest.IndirectMap, jsonSerializerOptions); + } + if (mapTest.MapMapOfStringOption.IsSet) + { + writer.WritePropertyName("map_map_of_string"); + JsonSerializer.Serialize(writer, mapTest.MapMapOfString, jsonSerializerOptions); + } + if (mapTest.MapOfEnumStringOption.IsSet) + { + writer.WritePropertyName("map_of_enum_string"); + JsonSerializer.Serialize(writer, mapTest.MapOfEnumString, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixLog.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixLog.cs new file mode 100644 index 000000000000..75cdeb1ec5b0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixLog.cs @@ -0,0 +1,1027 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixLog + /// + public partial class MixLog : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// description + /// formulaVersionDate + /// id + /// mixDate + /// totalOverPoors + /// totalRecalculations + /// totalSkips + /// totalUnderPours + /// batchNumber + /// BrandCode is only required for non-color mixes + /// BrandId is only required for color mixes + /// BrandName is only required for color mixes + /// CategoryCode is not used anymore + /// Color is only required for color mixes + /// colorDescription + /// comment + /// commercialProductCode + /// country + /// createdBy + /// createdByFirstName + /// createdByLastName + /// deltaECalculationRepaired + /// deltaECalculationSprayout + /// ownColorVariantNumber + /// primerProductId + /// ProductId is only required for color mixes + /// ProductLineCode is only required for color mixes + /// ProductName is only required for color mixes + /// selectedVersionIndex + /// shopId + /// SomeCode is only required for color mixes + /// totalPrice + [JsonConstructor] + public MixLog(string description, DateTime formulaVersionDate, Guid id, DateTime mixDate, int totalOverPoors, int totalRecalculations, int totalSkips, int totalUnderPours, Option batchNumber = default, Option brandCode = default, Option brandId = default, Option brandName = default, Option categoryCode = default, Option color = default, Option colorDescription = default, Option comment = default, Option commercialProductCode = default, Option country = default, Option createdBy = default, Option createdByFirstName = default, Option createdByLastName = default, Option deltaECalculationRepaired = default, Option deltaECalculationSprayout = default, Option ownColorVariantNumber = default, Option primerProductId = default, Option productId = default, Option productLineCode = default, Option productName = default, Option selectedVersionIndex = default, Option shopId = default, Option someCode = default, Option totalPrice = default) + { + Description = description; + FormulaVersionDate = formulaVersionDate; + Id = id; + MixDate = mixDate; + TotalOverPoors = totalOverPoors; + TotalRecalculations = totalRecalculations; + TotalSkips = totalSkips; + TotalUnderPours = totalUnderPours; + BatchNumberOption = batchNumber; + BrandCodeOption = brandCode; + BrandIdOption = brandId; + BrandNameOption = brandName; + CategoryCodeOption = categoryCode; + ColorOption = color; + ColorDescriptionOption = colorDescription; + CommentOption = comment; + CommercialProductCodeOption = commercialProductCode; + CountryOption = country; + CreatedByOption = createdBy; + CreatedByFirstNameOption = createdByFirstName; + CreatedByLastNameOption = createdByLastName; + DeltaECalculationRepairedOption = deltaECalculationRepaired; + DeltaECalculationSprayoutOption = deltaECalculationSprayout; + OwnColorVariantNumberOption = ownColorVariantNumber; + PrimerProductIdOption = primerProductId; + ProductIdOption = productId; + ProductLineCodeOption = productLineCode; + ProductNameOption = productName; + SelectedVersionIndexOption = selectedVersionIndex; + ShopIdOption = shopId; + SomeCodeOption = someCode; + TotalPriceOption = totalPrice; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Description + /// + [JsonPropertyName("description")] + public string Description { get; set; } + + /// + /// Gets or Sets FormulaVersionDate + /// + [JsonPropertyName("formulaVersionDate")] + public DateTime FormulaVersionDate { get; set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public Guid Id { get; set; } + + /// + /// Gets or Sets MixDate + /// + [JsonPropertyName("mixDate")] + public DateTime MixDate { get; set; } + + /// + /// Gets or Sets TotalOverPoors + /// + [JsonPropertyName("totalOverPoors")] + public int TotalOverPoors { get; set; } + + /// + /// Gets or Sets TotalRecalculations + /// + [JsonPropertyName("totalRecalculations")] + public int TotalRecalculations { get; set; } + + /// + /// Gets or Sets TotalSkips + /// + [JsonPropertyName("totalSkips")] + public int TotalSkips { get; set; } + + /// + /// Gets or Sets TotalUnderPours + /// + [JsonPropertyName("totalUnderPours")] + public int TotalUnderPours { get; set; } + + /// + /// Used to track the state of BatchNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BatchNumberOption { get; private set; } + + /// + /// Gets or Sets BatchNumber + /// + [JsonPropertyName("batchNumber")] + public string BatchNumber { get { return this.BatchNumberOption; } set { this.BatchNumberOption = new Option(value); } } + + /// + /// Used to track the state of BrandCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandCodeOption { get; private set; } + + /// + /// BrandCode is only required for non-color mixes + /// + /// BrandCode is only required for non-color mixes + [JsonPropertyName("brandCode")] + public string BrandCode { get { return this.BrandCodeOption; } set { this.BrandCodeOption = new Option(value); } } + + /// + /// Used to track the state of BrandId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandIdOption { get; private set; } + + /// + /// BrandId is only required for color mixes + /// + /// BrandId is only required for color mixes + [JsonPropertyName("brandId")] + public string BrandId { get { return this.BrandIdOption; } set { this.BrandIdOption = new Option(value); } } + + /// + /// Used to track the state of BrandName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BrandNameOption { get; private set; } + + /// + /// BrandName is only required for color mixes + /// + /// BrandName is only required for color mixes + [JsonPropertyName("brandName")] + public string BrandName { get { return this.BrandNameOption; } set { this.BrandNameOption = new Option(value); } } + + /// + /// Used to track the state of CategoryCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryCodeOption { get; private set; } + + /// + /// CategoryCode is not used anymore + /// + /// CategoryCode is not used anymore + [JsonPropertyName("categoryCode")] + public string CategoryCode { get { return this.CategoryCodeOption; } set { this.CategoryCodeOption = new Option(value); } } + + /// + /// Used to track the state of Color + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorOption { get; private set; } + + /// + /// Color is only required for color mixes + /// + /// Color is only required for color mixes + [JsonPropertyName("color")] + public string Color { get { return this.ColorOption; } set { this.ColorOption = new Option(value); } } + + /// + /// Used to track the state of ColorDescription + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ColorDescriptionOption { get; private set; } + + /// + /// Gets or Sets ColorDescription + /// + [JsonPropertyName("colorDescription")] + public string ColorDescription { get { return this.ColorDescriptionOption; } set { this.ColorDescriptionOption = new Option(value); } } + + /// + /// Used to track the state of Comment + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CommentOption { get; private set; } + + /// + /// Gets or Sets Comment + /// + [JsonPropertyName("comment")] + public string Comment { get { return this.CommentOption; } set { this.CommentOption = new Option(value); } } + + /// + /// Used to track the state of CommercialProductCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CommercialProductCodeOption { get; private set; } + + /// + /// Gets or Sets CommercialProductCode + /// + [JsonPropertyName("commercialProductCode")] + public string CommercialProductCode { get { return this.CommercialProductCodeOption; } set { this.CommercialProductCodeOption = new Option(value); } } + + /// + /// Used to track the state of Country + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CountryOption { get; private set; } + + /// + /// Gets or Sets Country + /// + [JsonPropertyName("country")] + public string Country { get { return this.CountryOption; } set { this.CountryOption = new Option(value); } } + + /// + /// Used to track the state of CreatedBy + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByOption { get; private set; } + + /// + /// Gets or Sets CreatedBy + /// + [JsonPropertyName("createdBy")] + public string CreatedBy { get { return this.CreatedByOption; } set { this.CreatedByOption = new Option(value); } } + + /// + /// Used to track the state of CreatedByFirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByFirstNameOption { get; private set; } + + /// + /// Gets or Sets CreatedByFirstName + /// + [JsonPropertyName("createdByFirstName")] + public string CreatedByFirstName { get { return this.CreatedByFirstNameOption; } set { this.CreatedByFirstNameOption = new Option(value); } } + + /// + /// Used to track the state of CreatedByLastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CreatedByLastNameOption { get; private set; } + + /// + /// Gets or Sets CreatedByLastName + /// + [JsonPropertyName("createdByLastName")] + public string CreatedByLastName { get { return this.CreatedByLastNameOption; } set { this.CreatedByLastNameOption = new Option(value); } } + + /// + /// Used to track the state of DeltaECalculationRepaired + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeltaECalculationRepairedOption { get; private set; } + + /// + /// Gets or Sets DeltaECalculationRepaired + /// + [JsonPropertyName("deltaECalculationRepaired")] + public string DeltaECalculationRepaired { get { return this.DeltaECalculationRepairedOption; } set { this.DeltaECalculationRepairedOption = new Option(value); } } + + /// + /// Used to track the state of DeltaECalculationSprayout + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeltaECalculationSprayoutOption { get; private set; } + + /// + /// Gets or Sets DeltaECalculationSprayout + /// + [JsonPropertyName("deltaECalculationSprayout")] + public string DeltaECalculationSprayout { get { return this.DeltaECalculationSprayoutOption; } set { this.DeltaECalculationSprayoutOption = new Option(value); } } + + /// + /// Used to track the state of OwnColorVariantNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option OwnColorVariantNumberOption { get; private set; } + + /// + /// Gets or Sets OwnColorVariantNumber + /// + [JsonPropertyName("ownColorVariantNumber")] + public int? OwnColorVariantNumber { get { return this.OwnColorVariantNumberOption; } set { this.OwnColorVariantNumberOption = new Option(value); } } + + /// + /// Used to track the state of PrimerProductId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PrimerProductIdOption { get; private set; } + + /// + /// Gets or Sets PrimerProductId + /// + [JsonPropertyName("primerProductId")] + public string PrimerProductId { get { return this.PrimerProductIdOption; } set { this.PrimerProductIdOption = new Option(value); } } + + /// + /// Used to track the state of ProductId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductIdOption { get; private set; } + + /// + /// ProductId is only required for color mixes + /// + /// ProductId is only required for color mixes + [JsonPropertyName("productId")] + public string ProductId { get { return this.ProductIdOption; } set { this.ProductIdOption = new Option(value); } } + + /// + /// Used to track the state of ProductLineCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductLineCodeOption { get; private set; } + + /// + /// ProductLineCode is only required for color mixes + /// + /// ProductLineCode is only required for color mixes + [JsonPropertyName("productLineCode")] + public string ProductLineCode { get { return this.ProductLineCodeOption; } set { this.ProductLineCodeOption = new Option(value); } } + + /// + /// Used to track the state of ProductName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ProductNameOption { get; private set; } + + /// + /// ProductName is only required for color mixes + /// + /// ProductName is only required for color mixes + [JsonPropertyName("productName")] + public string ProductName { get { return this.ProductNameOption; } set { this.ProductNameOption = new Option(value); } } + + /// + /// Used to track the state of SelectedVersionIndex + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SelectedVersionIndexOption { get; private set; } + + /// + /// Gets or Sets SelectedVersionIndex + /// + [JsonPropertyName("selectedVersionIndex")] + public int? SelectedVersionIndex { get { return this.SelectedVersionIndexOption; } set { this.SelectedVersionIndexOption = new Option(value); } } + + /// + /// Used to track the state of ShopId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShopIdOption { get; private set; } + + /// + /// Gets or Sets ShopId + /// + [JsonPropertyName("shopId")] + public Guid? ShopId { get { return this.ShopIdOption; } set { this.ShopIdOption = new Option(value); } } + + /// + /// Used to track the state of SomeCode + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomeCodeOption { get; private set; } + + /// + /// SomeCode is only required for color mixes + /// + /// SomeCode is only required for color mixes + [JsonPropertyName("someCode")] + public string SomeCode { get { return this.SomeCodeOption; } set { this.SomeCodeOption = new Option(value); } } + + /// + /// Used to track the state of TotalPrice + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TotalPriceOption { get; private set; } + + /// + /// Gets or Sets TotalPrice + /// + [JsonPropertyName("totalPrice")] + public float? TotalPrice { get { return this.TotalPriceOption; } set { this.TotalPriceOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixLog {\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append(" FormulaVersionDate: ").Append(FormulaVersionDate).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" MixDate: ").Append(MixDate).Append("\n"); + sb.Append(" TotalOverPoors: ").Append(TotalOverPoors).Append("\n"); + sb.Append(" TotalRecalculations: ").Append(TotalRecalculations).Append("\n"); + sb.Append(" TotalSkips: ").Append(TotalSkips).Append("\n"); + sb.Append(" TotalUnderPours: ").Append(TotalUnderPours).Append("\n"); + sb.Append(" BatchNumber: ").Append(BatchNumber).Append("\n"); + sb.Append(" BrandCode: ").Append(BrandCode).Append("\n"); + sb.Append(" BrandId: ").Append(BrandId).Append("\n"); + sb.Append(" BrandName: ").Append(BrandName).Append("\n"); + sb.Append(" CategoryCode: ").Append(CategoryCode).Append("\n"); + sb.Append(" Color: ").Append(Color).Append("\n"); + sb.Append(" ColorDescription: ").Append(ColorDescription).Append("\n"); + sb.Append(" Comment: ").Append(Comment).Append("\n"); + sb.Append(" CommercialProductCode: ").Append(CommercialProductCode).Append("\n"); + sb.Append(" Country: ").Append(Country).Append("\n"); + sb.Append(" CreatedBy: ").Append(CreatedBy).Append("\n"); + sb.Append(" CreatedByFirstName: ").Append(CreatedByFirstName).Append("\n"); + sb.Append(" CreatedByLastName: ").Append(CreatedByLastName).Append("\n"); + sb.Append(" DeltaECalculationRepaired: ").Append(DeltaECalculationRepaired).Append("\n"); + sb.Append(" DeltaECalculationSprayout: ").Append(DeltaECalculationSprayout).Append("\n"); + sb.Append(" OwnColorVariantNumber: ").Append(OwnColorVariantNumber).Append("\n"); + sb.Append(" PrimerProductId: ").Append(PrimerProductId).Append("\n"); + sb.Append(" ProductId: ").Append(ProductId).Append("\n"); + sb.Append(" ProductLineCode: ").Append(ProductLineCode).Append("\n"); + sb.Append(" ProductName: ").Append(ProductName).Append("\n"); + sb.Append(" SelectedVersionIndex: ").Append(SelectedVersionIndex).Append("\n"); + sb.Append(" ShopId: ").Append(ShopId).Append("\n"); + sb.Append(" SomeCode: ").Append(SomeCode).Append("\n"); + sb.Append(" TotalPrice: ").Append(TotalPrice).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MixLogJsonConverter : JsonConverter + { + /// + /// The format to use to serialize FormulaVersionDate + /// + public static string FormulaVersionDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize MixDate + /// + public static string MixDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixLog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option description = default; + Option formulaVersionDate = default; + Option id = default; + Option mixDate = default; + Option totalOverPoors = default; + Option totalRecalculations = default; + Option totalSkips = default; + Option totalUnderPours = default; + Option batchNumber = default; + Option brandCode = default; + Option brandId = default; + Option brandName = default; + Option categoryCode = default; + Option color = default; + Option colorDescription = default; + Option comment = default; + Option commercialProductCode = default; + Option country = default; + Option createdBy = default; + Option createdByFirstName = default; + Option createdByLastName = default; + Option deltaECalculationRepaired = default; + Option deltaECalculationSprayout = default; + Option ownColorVariantNumber = default; + Option primerProductId = default; + Option productId = default; + Option productLineCode = default; + Option productName = default; + Option selectedVersionIndex = default; + Option shopId = default; + Option someCode = default; + Option totalPrice = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "description": + description = new Option(utf8JsonReader.GetString()); + break; + case "formulaVersionDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + formulaVersionDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetGuid()); + break; + case "mixDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + mixDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "totalOverPoors": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalOverPoors = new Option(utf8JsonReader.GetInt32()); + break; + case "totalRecalculations": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalRecalculations = new Option(utf8JsonReader.GetInt32()); + break; + case "totalSkips": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalSkips = new Option(utf8JsonReader.GetInt32()); + break; + case "totalUnderPours": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalUnderPours = new Option(utf8JsonReader.GetInt32()); + break; + case "batchNumber": + batchNumber = new Option(utf8JsonReader.GetString()); + break; + case "brandCode": + brandCode = new Option(utf8JsonReader.GetString()); + break; + case "brandId": + brandId = new Option(utf8JsonReader.GetString()); + break; + case "brandName": + brandName = new Option(utf8JsonReader.GetString()); + break; + case "categoryCode": + categoryCode = new Option(utf8JsonReader.GetString()); + break; + case "color": + color = new Option(utf8JsonReader.GetString()); + break; + case "colorDescription": + colorDescription = new Option(utf8JsonReader.GetString()); + break; + case "comment": + comment = new Option(utf8JsonReader.GetString()); + break; + case "commercialProductCode": + commercialProductCode = new Option(utf8JsonReader.GetString()); + break; + case "country": + country = new Option(utf8JsonReader.GetString()); + break; + case "createdBy": + createdBy = new Option(utf8JsonReader.GetString()); + break; + case "createdByFirstName": + createdByFirstName = new Option(utf8JsonReader.GetString()); + break; + case "createdByLastName": + createdByLastName = new Option(utf8JsonReader.GetString()); + break; + case "deltaECalculationRepaired": + deltaECalculationRepaired = new Option(utf8JsonReader.GetString()); + break; + case "deltaECalculationSprayout": + deltaECalculationSprayout = new Option(utf8JsonReader.GetString()); + break; + case "ownColorVariantNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + ownColorVariantNumber = new Option(utf8JsonReader.GetInt32()); + break; + case "primerProductId": + primerProductId = new Option(utf8JsonReader.GetString()); + break; + case "productId": + productId = new Option(utf8JsonReader.GetString()); + break; + case "productLineCode": + productLineCode = new Option(utf8JsonReader.GetString()); + break; + case "productName": + productName = new Option(utf8JsonReader.GetString()); + break; + case "selectedVersionIndex": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + selectedVersionIndex = new Option(utf8JsonReader.GetInt32()); + break; + case "shopId": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shopId = new Option(utf8JsonReader.GetGuid()); + break; + case "someCode": + someCode = new Option(utf8JsonReader.GetString()); + break; + case "totalPrice": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + totalPrice = new Option((float)utf8JsonReader.GetDouble()); + break; + default: + break; + } + } + } + + if (!description.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(description)); + + if (!formulaVersionDate.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(formulaVersionDate)); + + if (!id.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(id)); + + if (!mixDate.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(mixDate)); + + if (!totalOverPoors.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalOverPoors)); + + if (!totalRecalculations.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalRecalculations)); + + if (!totalSkips.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalSkips)); + + if (!totalUnderPours.IsSet) + throw new ArgumentException("Property is required for class MixLog.", nameof(totalUnderPours)); + + if (description.IsSet && description.Value == null) + throw new ArgumentNullException(nameof(description), "Property is not nullable for class MixLog."); + + if (formulaVersionDate.IsSet && formulaVersionDate.Value == null) + throw new ArgumentNullException(nameof(formulaVersionDate), "Property is not nullable for class MixLog."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixLog."); + + if (mixDate.IsSet && mixDate.Value == null) + throw new ArgumentNullException(nameof(mixDate), "Property is not nullable for class MixLog."); + + if (totalOverPoors.IsSet && totalOverPoors.Value == null) + throw new ArgumentNullException(nameof(totalOverPoors), "Property is not nullable for class MixLog."); + + if (totalRecalculations.IsSet && totalRecalculations.Value == null) + throw new ArgumentNullException(nameof(totalRecalculations), "Property is not nullable for class MixLog."); + + if (totalSkips.IsSet && totalSkips.Value == null) + throw new ArgumentNullException(nameof(totalSkips), "Property is not nullable for class MixLog."); + + if (totalUnderPours.IsSet && totalUnderPours.Value == null) + throw new ArgumentNullException(nameof(totalUnderPours), "Property is not nullable for class MixLog."); + + if (batchNumber.IsSet && batchNumber.Value == null) + throw new ArgumentNullException(nameof(batchNumber), "Property is not nullable for class MixLog."); + + if (brandCode.IsSet && brandCode.Value == null) + throw new ArgumentNullException(nameof(brandCode), "Property is not nullable for class MixLog."); + + if (brandId.IsSet && brandId.Value == null) + throw new ArgumentNullException(nameof(brandId), "Property is not nullable for class MixLog."); + + if (brandName.IsSet && brandName.Value == null) + throw new ArgumentNullException(nameof(brandName), "Property is not nullable for class MixLog."); + + if (categoryCode.IsSet && categoryCode.Value == null) + throw new ArgumentNullException(nameof(categoryCode), "Property is not nullable for class MixLog."); + + if (color.IsSet && color.Value == null) + throw new ArgumentNullException(nameof(color), "Property is not nullable for class MixLog."); + + if (colorDescription.IsSet && colorDescription.Value == null) + throw new ArgumentNullException(nameof(colorDescription), "Property is not nullable for class MixLog."); + + if (comment.IsSet && comment.Value == null) + throw new ArgumentNullException(nameof(comment), "Property is not nullable for class MixLog."); + + if (commercialProductCode.IsSet && commercialProductCode.Value == null) + throw new ArgumentNullException(nameof(commercialProductCode), "Property is not nullable for class MixLog."); + + if (country.IsSet && country.Value == null) + throw new ArgumentNullException(nameof(country), "Property is not nullable for class MixLog."); + + if (createdBy.IsSet && createdBy.Value == null) + throw new ArgumentNullException(nameof(createdBy), "Property is not nullable for class MixLog."); + + if (createdByFirstName.IsSet && createdByFirstName.Value == null) + throw new ArgumentNullException(nameof(createdByFirstName), "Property is not nullable for class MixLog."); + + if (createdByLastName.IsSet && createdByLastName.Value == null) + throw new ArgumentNullException(nameof(createdByLastName), "Property is not nullable for class MixLog."); + + if (deltaECalculationRepaired.IsSet && deltaECalculationRepaired.Value == null) + throw new ArgumentNullException(nameof(deltaECalculationRepaired), "Property is not nullable for class MixLog."); + + if (deltaECalculationSprayout.IsSet && deltaECalculationSprayout.Value == null) + throw new ArgumentNullException(nameof(deltaECalculationSprayout), "Property is not nullable for class MixLog."); + + if (primerProductId.IsSet && primerProductId.Value == null) + throw new ArgumentNullException(nameof(primerProductId), "Property is not nullable for class MixLog."); + + if (productId.IsSet && productId.Value == null) + throw new ArgumentNullException(nameof(productId), "Property is not nullable for class MixLog."); + + if (productLineCode.IsSet && productLineCode.Value == null) + throw new ArgumentNullException(nameof(productLineCode), "Property is not nullable for class MixLog."); + + if (productName.IsSet && productName.Value == null) + throw new ArgumentNullException(nameof(productName), "Property is not nullable for class MixLog."); + + if (selectedVersionIndex.IsSet && selectedVersionIndex.Value == null) + throw new ArgumentNullException(nameof(selectedVersionIndex), "Property is not nullable for class MixLog."); + + if (shopId.IsSet && shopId.Value == null) + throw new ArgumentNullException(nameof(shopId), "Property is not nullable for class MixLog."); + + return new MixLog(description.Value, formulaVersionDate.Value.Value, id.Value.Value, mixDate.Value.Value, totalOverPoors.Value.Value, totalRecalculations.Value.Value, totalSkips.Value.Value, totalUnderPours.Value.Value, batchNumber, brandCode, brandId, brandName, categoryCode, color, colorDescription, comment, commercialProductCode, country, createdBy, createdByFirstName, createdByLastName, deltaECalculationRepaired, deltaECalculationSprayout, ownColorVariantNumber, primerProductId, productId, productLineCode, productName, selectedVersionIndex, shopId, someCode, totalPrice); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixLog mixLog, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixLog, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixLog mixLog, JsonSerializerOptions jsonSerializerOptions) + { + if (mixLog.Description == null) + throw new ArgumentNullException(nameof(mixLog.Description), "Property is required for class MixLog."); + + if (mixLog.BatchNumberOption.IsSet && mixLog.BatchNumber == null) + throw new ArgumentNullException(nameof(mixLog.BatchNumber), "Property is required for class MixLog."); + + if (mixLog.BrandCodeOption.IsSet && mixLog.BrandCode == null) + throw new ArgumentNullException(nameof(mixLog.BrandCode), "Property is required for class MixLog."); + + if (mixLog.BrandIdOption.IsSet && mixLog.BrandId == null) + throw new ArgumentNullException(nameof(mixLog.BrandId), "Property is required for class MixLog."); + + if (mixLog.BrandNameOption.IsSet && mixLog.BrandName == null) + throw new ArgumentNullException(nameof(mixLog.BrandName), "Property is required for class MixLog."); + + if (mixLog.CategoryCodeOption.IsSet && mixLog.CategoryCode == null) + throw new ArgumentNullException(nameof(mixLog.CategoryCode), "Property is required for class MixLog."); + + if (mixLog.ColorOption.IsSet && mixLog.Color == null) + throw new ArgumentNullException(nameof(mixLog.Color), "Property is required for class MixLog."); + + if (mixLog.ColorDescriptionOption.IsSet && mixLog.ColorDescription == null) + throw new ArgumentNullException(nameof(mixLog.ColorDescription), "Property is required for class MixLog."); + + if (mixLog.CommentOption.IsSet && mixLog.Comment == null) + throw new ArgumentNullException(nameof(mixLog.Comment), "Property is required for class MixLog."); + + if (mixLog.CommercialProductCodeOption.IsSet && mixLog.CommercialProductCode == null) + throw new ArgumentNullException(nameof(mixLog.CommercialProductCode), "Property is required for class MixLog."); + + if (mixLog.CountryOption.IsSet && mixLog.Country == null) + throw new ArgumentNullException(nameof(mixLog.Country), "Property is required for class MixLog."); + + if (mixLog.CreatedByOption.IsSet && mixLog.CreatedBy == null) + throw new ArgumentNullException(nameof(mixLog.CreatedBy), "Property is required for class MixLog."); + + if (mixLog.CreatedByFirstNameOption.IsSet && mixLog.CreatedByFirstName == null) + throw new ArgumentNullException(nameof(mixLog.CreatedByFirstName), "Property is required for class MixLog."); + + if (mixLog.CreatedByLastNameOption.IsSet && mixLog.CreatedByLastName == null) + throw new ArgumentNullException(nameof(mixLog.CreatedByLastName), "Property is required for class MixLog."); + + if (mixLog.DeltaECalculationRepairedOption.IsSet && mixLog.DeltaECalculationRepaired == null) + throw new ArgumentNullException(nameof(mixLog.DeltaECalculationRepaired), "Property is required for class MixLog."); + + if (mixLog.DeltaECalculationSprayoutOption.IsSet && mixLog.DeltaECalculationSprayout == null) + throw new ArgumentNullException(nameof(mixLog.DeltaECalculationSprayout), "Property is required for class MixLog."); + + if (mixLog.PrimerProductIdOption.IsSet && mixLog.PrimerProductId == null) + throw new ArgumentNullException(nameof(mixLog.PrimerProductId), "Property is required for class MixLog."); + + if (mixLog.ProductIdOption.IsSet && mixLog.ProductId == null) + throw new ArgumentNullException(nameof(mixLog.ProductId), "Property is required for class MixLog."); + + if (mixLog.ProductLineCodeOption.IsSet && mixLog.ProductLineCode == null) + throw new ArgumentNullException(nameof(mixLog.ProductLineCode), "Property is required for class MixLog."); + + if (mixLog.ProductNameOption.IsSet && mixLog.ProductName == null) + throw new ArgumentNullException(nameof(mixLog.ProductName), "Property is required for class MixLog."); + + writer.WriteString("description", mixLog.Description); + + writer.WriteString("formulaVersionDate", mixLog.FormulaVersionDate.ToString(FormulaVersionDateFormat)); + + writer.WriteString("id", mixLog.Id); + + writer.WriteString("mixDate", mixLog.MixDate.ToString(MixDateFormat)); + + writer.WriteNumber("totalOverPoors", mixLog.TotalOverPoors); + + writer.WriteNumber("totalRecalculations", mixLog.TotalRecalculations); + + writer.WriteNumber("totalSkips", mixLog.TotalSkips); + + writer.WriteNumber("totalUnderPours", mixLog.TotalUnderPours); + + if (mixLog.BatchNumberOption.IsSet) + writer.WriteString("batchNumber", mixLog.BatchNumber); + + if (mixLog.BrandCodeOption.IsSet) + writer.WriteString("brandCode", mixLog.BrandCode); + + if (mixLog.BrandIdOption.IsSet) + writer.WriteString("brandId", mixLog.BrandId); + + if (mixLog.BrandNameOption.IsSet) + writer.WriteString("brandName", mixLog.BrandName); + + if (mixLog.CategoryCodeOption.IsSet) + writer.WriteString("categoryCode", mixLog.CategoryCode); + + if (mixLog.ColorOption.IsSet) + writer.WriteString("color", mixLog.Color); + + if (mixLog.ColorDescriptionOption.IsSet) + writer.WriteString("colorDescription", mixLog.ColorDescription); + + if (mixLog.CommentOption.IsSet) + writer.WriteString("comment", mixLog.Comment); + + if (mixLog.CommercialProductCodeOption.IsSet) + writer.WriteString("commercialProductCode", mixLog.CommercialProductCode); + + if (mixLog.CountryOption.IsSet) + writer.WriteString("country", mixLog.Country); + + if (mixLog.CreatedByOption.IsSet) + writer.WriteString("createdBy", mixLog.CreatedBy); + + if (mixLog.CreatedByFirstNameOption.IsSet) + writer.WriteString("createdByFirstName", mixLog.CreatedByFirstName); + + if (mixLog.CreatedByLastNameOption.IsSet) + writer.WriteString("createdByLastName", mixLog.CreatedByLastName); + + if (mixLog.DeltaECalculationRepairedOption.IsSet) + writer.WriteString("deltaECalculationRepaired", mixLog.DeltaECalculationRepaired); + + if (mixLog.DeltaECalculationSprayoutOption.IsSet) + writer.WriteString("deltaECalculationSprayout", mixLog.DeltaECalculationSprayout); + + if (mixLog.OwnColorVariantNumberOption.IsSet) + if (mixLog.OwnColorVariantNumberOption.Value != null) + writer.WriteNumber("ownColorVariantNumber", mixLog.OwnColorVariantNumberOption.Value.Value); + else + writer.WriteNull("ownColorVariantNumber"); + + if (mixLog.PrimerProductIdOption.IsSet) + writer.WriteString("primerProductId", mixLog.PrimerProductId); + + if (mixLog.ProductIdOption.IsSet) + writer.WriteString("productId", mixLog.ProductId); + + if (mixLog.ProductLineCodeOption.IsSet) + writer.WriteString("productLineCode", mixLog.ProductLineCode); + + if (mixLog.ProductNameOption.IsSet) + writer.WriteString("productName", mixLog.ProductName); + + if (mixLog.SelectedVersionIndexOption.IsSet) + writer.WriteNumber("selectedVersionIndex", mixLog.SelectedVersionIndexOption.Value.Value); + + if (mixLog.ShopIdOption.IsSet) + writer.WriteString("shopId", mixLog.ShopIdOption.Value.Value); + + if (mixLog.SomeCodeOption.IsSet) + if (mixLog.SomeCodeOption.Value != null) + writer.WriteString("someCode", mixLog.SomeCode); + else + writer.WriteNull("someCode"); + + if (mixLog.TotalPriceOption.IsSet) + if (mixLog.TotalPriceOption.Value != null) + writer.WriteNumber("totalPrice", mixLog.TotalPriceOption.Value.Value); + else + writer.WriteNull("totalPrice"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs new file mode 100644 index 000000000000..095c00f45621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -0,0 +1,270 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedPropertiesAndAdditionalPropertiesClass + /// + public partial class MixedPropertiesAndAdditionalPropertiesClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateTime + /// map + /// uuid + /// uuidWithPattern + [JsonConstructor] + public MixedPropertiesAndAdditionalPropertiesClass(Option dateTime = default, Option> map = default, Option uuid = default, Option uuidWithPattern = default) + { + DateTimeOption = dateTime; + MapOption = map; + UuidOption = uuid; + UuidWithPatternOption = uuidWithPattern; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of DateTime + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DateTimeOption { get; private set; } + + /// + /// Gets or Sets DateTime + /// + [JsonPropertyName("dateTime")] + public DateTime? DateTime { get { return this.DateTimeOption; } set { this.DateTimeOption = new Option(value); } } + + /// + /// Used to track the state of Map + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> MapOption { get; private set; } + + /// + /// Gets or Sets Map + /// + [JsonPropertyName("map")] + public Dictionary Map { get { return this.MapOption; } set { this.MapOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Used to track the state of UuidWithPattern + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidWithPatternOption { get; private set; } + + /// + /// Gets or Sets UuidWithPattern + /// + [JsonPropertyName("uuid_with_pattern")] + public Guid? UuidWithPattern { get { return this.UuidWithPatternOption; } set { this.UuidWithPatternOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + sb.Append(" Map: ").Append(Map).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" UuidWithPattern: ").Append(UuidWithPattern).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + // UuidWithPattern (Guid) pattern + Regex regexUuidWithPattern = new Regex(@"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", RegexOptions.CultureInvariant); + + if (this.UuidWithPatternOption.Value != null &&!regexUuidWithPattern.Match(this.UuidWithPatternOption.Value.ToString()).Success) + { + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UuidWithPattern, must match a pattern of " + regexUuidWithPattern, new [] { "UuidWithPattern" }); + } + yield break; + } + } + + /// + /// A Json converter for type + /// + public class MixedPropertiesAndAdditionalPropertiesClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateTime + /// + public static string DateTimeFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option dateTime = default; + Option> map = default; + Option uuid = default; + Option uuidWithPattern = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "dateTime": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateTime = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "map": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + map = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + case "uuid_with_pattern": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuidWithPattern = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (dateTime.IsSet && dateTime.Value == null) + throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (map.IsSet && map.Value == null) + throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (uuidWithPattern.IsSet && uuidWithPattern.Value == null) + throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass."); + + return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null) + throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass."); + + if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet) + writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value.Value.ToString(DateTimeFormat)); + + if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet) + { + writer.WritePropertyName("map"); + JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions); + } + if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet) + writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value.Value); + + if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet) + writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs new file mode 100644 index 000000000000..8c0a59ace8bd --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model name starting with number + /// + public partial class Model200Response : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// class + /// name + [JsonConstructor] + public Model200Response(Option @class = default, Option name = default) + { + ClassOption = @class; + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Class + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ClassOption { get; private set; } + + /// + /// Gets or Sets Class + /// + [JsonPropertyName("class")] + public string Class { get { return this.ClassOption; } set { this.ClassOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public int? Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Model200Response {\n"); + sb.Append(" Class: ").Append(Class).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class Model200ResponseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClass = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "class": + varClass = new Option(utf8JsonReader.GetString()); + break; + case "name": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + name = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (varClass.IsSet && varClass.Value == null) + throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response."); + + return new Model200Response(varClass, name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, model200Response, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + { + if (model200Response.ClassOption.IsSet && model200Response.Class == null) + throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response."); + + if (model200Response.ClassOption.IsSet) + writer.WriteString("class", model200Response.Class); + + if (model200Response.NameOption.IsSet) + writer.WriteNumber("name", model200Response.NameOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs new file mode 100644 index 000000000000..e8cca355d288 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ModelClient + /// + public partial class ModelClient : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varClient + [JsonConstructor] + public ModelClient(Option varClient = default) + { + VarClientOption = varClient; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of VarClient + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarClientOption { get; private set; } + + /// + /// Gets or Sets VarClient + /// + [JsonPropertyName("client")] + public string VarClient { get { return this.VarClientOption; } set { this.VarClientOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ModelClient {\n"); + sb.Append(" VarClient: ").Append(VarClient).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ModelClientJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varClient = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "client": + varClient = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (varClient.IsSet && varClient.Value == null) + throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient."); + + return new ModelClient(varClient); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, modelClient, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + { + if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null) + throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient."); + + if (modelClient.VarClientOption.IsSet) + writer.WriteString("client", modelClient.VarClient); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs new file mode 100644 index 000000000000..90a80bda8815 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Name.cs @@ -0,0 +1,291 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing model name same as property name + /// + public partial class Name : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varName + /// property + /// snakeCase + /// var123Number + [JsonConstructor] + public Name(int varName, Option property = default, Option snakeCase = default, Option var123Number = default) + { + VarName = varName; + PropertyOption = property; + SnakeCaseOption = snakeCase; + Var123NumberOption = var123Number; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets VarName + /// + [JsonPropertyName("name")] + public int VarName { get; set; } + + /// + /// Used to track the state of Property + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PropertyOption { get; private set; } + + /// + /// Gets or Sets Property + /// + [JsonPropertyName("property")] + public string Property { get { return this.PropertyOption; } set { this.PropertyOption = new Option(value); } } + + /// + /// Used to track the state of SnakeCase + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SnakeCaseOption { get; } + + /// + /// Gets or Sets SnakeCase + /// + [JsonPropertyName("snake_case")] + public int? SnakeCase { get { return this.SnakeCaseOption; } } + + /// + /// Used to track the state of Var123Number + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option Var123NumberOption { get; } + + /// + /// Gets or Sets Var123Number + /// + [JsonPropertyName("123Number")] + public int? Var123Number { get { return this.Var123NumberOption; } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Name {\n"); + sb.Append(" VarName: ").Append(VarName).Append("\n"); + sb.Append(" Property: ").Append(Property).Append("\n"); + sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); + sb.Append(" Var123Number: ").Append(Var123Number).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as Name).AreEqual; + } + + /// + /// Returns true if Name instances are equal + /// + /// Instance of Name to be compared + /// Boolean + public bool Equals(Name input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (SnakeCase != null) + hashCode = (hashCode * 59) + SnakeCase.GetHashCode(); + + if (Var123Number != null) + hashCode = (hashCode * 59) + Var123Number.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NameJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varName = default; + Option property = default; + Option snakeCase = default; + Option var123Number = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varName = new Option(utf8JsonReader.GetInt32()); + break; + case "property": + property = new Option(utf8JsonReader.GetString()); + break; + case "snake_case": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + snakeCase = new Option(utf8JsonReader.GetInt32()); + break; + case "123Number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + var123Number = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (!varName.IsSet) + throw new ArgumentException("Property is required for class Name.", nameof(varName)); + + if (varName.IsSet && varName.Value == null) + throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name."); + + if (property.IsSet && property.Value == null) + throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name."); + + if (snakeCase.IsSet && snakeCase.Value == null) + throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name."); + + if (var123Number.IsSet && var123Number.Value == null) + throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name."); + + return new Name(varName.Value.Value, property, snakeCase, var123Number); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, name, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + { + if (name.PropertyOption.IsSet && name.Property == null) + throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name."); + + writer.WriteNumber("name", name.VarName); + + if (name.PropertyOption.IsSet) + writer.WriteString("property", name.Property); + + if (name.SnakeCaseOption.IsSet) + writer.WriteNumber("snake_case", name.SnakeCaseOption.Value.Value); + + if (name.Var123NumberOption.IsSet) + writer.WriteNumber("123Number", name.Var123NumberOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs new file mode 100644 index 000000000000..d10268f2927a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -0,0 +1,192 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NotificationtestGetElementsV1ResponseMPayload + /// + public partial class NotificationtestGetElementsV1ResponseMPayload : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// aObjVariableobject + /// pkiNotificationtestID + [JsonConstructor] + public NotificationtestGetElementsV1ResponseMPayload(List> aObjVariableobject, int pkiNotificationtestID) + { + AObjVariableobject = aObjVariableobject; + PkiNotificationtestID = pkiNotificationtestID; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets AObjVariableobject + /// + [JsonPropertyName("a_objVariableobject")] + public List> AObjVariableobject { get; set; } + + /// + /// Gets or Sets PkiNotificationtestID + /// + [JsonPropertyName("pkiNotificationtestID")] + public int PkiNotificationtestID { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NotificationtestGetElementsV1ResponseMPayload {\n"); + sb.Append(" AObjVariableobject: ").Append(AObjVariableobject).Append("\n"); + sb.Append(" PkiNotificationtestID: ").Append(PkiNotificationtestID).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NotificationtestGetElementsV1ResponseMPayloadJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NotificationtestGetElementsV1ResponseMPayload Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option>> aObjVariableobject = default; + Option pkiNotificationtestID = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "a_objVariableobject": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + aObjVariableobject = new Option>>(JsonSerializer.Deserialize>>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "pkiNotificationtestID": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + pkiNotificationtestID = new Option(utf8JsonReader.GetInt32()); + break; + default: + break; + } + } + } + + if (!aObjVariableobject.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(aObjVariableobject)); + + if (!pkiNotificationtestID.IsSet) + throw new ArgumentException("Property is required for class NotificationtestGetElementsV1ResponseMPayload.", nameof(pkiNotificationtestID)); + + if (aObjVariableobject.IsSet && aObjVariableobject.Value == null) + throw new ArgumentNullException(nameof(aObjVariableobject), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + if (pkiNotificationtestID.IsSet && pkiNotificationtestID.Value == null) + throw new ArgumentNullException(nameof(pkiNotificationtestID), "Property is not nullable for class NotificationtestGetElementsV1ResponseMPayload."); + + return new NotificationtestGetElementsV1ResponseMPayload(aObjVariableobject.Value, pkiNotificationtestID.Value.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + { + if (notificationtestGetElementsV1ResponseMPayload.AObjVariableobject == null) + throw new ArgumentNullException(nameof(notificationtestGetElementsV1ResponseMPayload.AObjVariableobject), "Property is required for class NotificationtestGetElementsV1ResponseMPayload."); + + writer.WritePropertyName("a_objVariableobject"); + JsonSerializer.Serialize(writer, notificationtestGetElementsV1ResponseMPayload.AObjVariableobject, jsonSerializerOptions); + writer.WriteNumber("pkiNotificationtestID", notificationtestGetElementsV1ResponseMPayload.PkiNotificationtestID); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs new file mode 100644 index 000000000000..f844fec808c5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs @@ -0,0 +1,496 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NullableClass + /// + public partial class NullableClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// arrayAndItemsNullableProp + /// arrayItemsNullable + /// arrayNullableProp + /// booleanProp + /// dateProp + /// datetimeProp + /// integerProp + /// numberProp + /// objectAndItemsNullableProp + /// objectItemsNullable + /// objectNullableProp + /// stringProp + [JsonConstructor] + public NullableClass(Option> arrayAndItemsNullableProp = default, Option> arrayItemsNullable = default, Option> arrayNullableProp = default, Option booleanProp = default, Option dateProp = default, Option datetimeProp = default, Option integerProp = default, Option numberProp = default, Option> objectAndItemsNullableProp = default, Option> objectItemsNullable = default, Option> objectNullableProp = default, Option stringProp = default) + { + ArrayAndItemsNullablePropOption = arrayAndItemsNullableProp; + ArrayItemsNullableOption = arrayItemsNullable; + ArrayNullablePropOption = arrayNullableProp; + BooleanPropOption = booleanProp; + DatePropOption = dateProp; + DatetimePropOption = datetimeProp; + IntegerPropOption = integerProp; + NumberPropOption = numberProp; + ObjectAndItemsNullablePropOption = objectAndItemsNullableProp; + ObjectItemsNullableOption = objectItemsNullable; + ObjectNullablePropOption = objectNullableProp; + StringPropOption = stringProp; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of ArrayAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayAndItemsNullablePropOption { get; private set; } + + /// + /// Gets or Sets ArrayAndItemsNullableProp + /// + [JsonPropertyName("array_and_items_nullable_prop")] + public List ArrayAndItemsNullableProp { get { return this.ArrayAndItemsNullablePropOption; } set { this.ArrayAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ArrayItemsNullable + /// + [JsonPropertyName("array_items_nullable")] + public List ArrayItemsNullable { get { return this.ArrayItemsNullableOption; } set { this.ArrayItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ArrayNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ArrayNullablePropOption { get; private set; } + + /// + /// Gets or Sets ArrayNullableProp + /// + [JsonPropertyName("array_nullable_prop")] + public List ArrayNullableProp { get { return this.ArrayNullablePropOption; } set { this.ArrayNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of BooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BooleanPropOption { get; private set; } + + /// + /// Gets or Sets BooleanProp + /// + [JsonPropertyName("boolean_prop")] + public bool? BooleanProp { get { return this.BooleanPropOption; } set { this.BooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of DateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatePropOption { get; private set; } + + /// + /// Gets or Sets DateProp + /// + [JsonPropertyName("date_prop")] + public DateTime? DateProp { get { return this.DatePropOption; } set { this.DatePropOption = new Option(value); } } + + /// + /// Used to track the state of DatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DatetimePropOption { get; private set; } + + /// + /// Gets or Sets DatetimeProp + /// + [JsonPropertyName("datetime_prop")] + public DateTime? DatetimeProp { get { return this.DatetimePropOption; } set { this.DatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of IntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntegerPropOption { get; private set; } + + /// + /// Gets or Sets IntegerProp + /// + [JsonPropertyName("integer_prop")] + public int? IntegerProp { get { return this.IntegerPropOption; } set { this.IntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NumberProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NumberPropOption { get; private set; } + + /// + /// Gets or Sets NumberProp + /// + [JsonPropertyName("number_prop")] + public decimal? NumberProp { get { return this.NumberPropOption; } set { this.NumberPropOption = new Option(value); } } + + /// + /// Used to track the state of ObjectAndItemsNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectAndItemsNullablePropOption { get; private set; } + + /// + /// Gets or Sets ObjectAndItemsNullableProp + /// + [JsonPropertyName("object_and_items_nullable_prop")] + public Dictionary ObjectAndItemsNullableProp { get { return this.ObjectAndItemsNullablePropOption; } set { this.ObjectAndItemsNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectItemsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectItemsNullableOption { get; private set; } + + /// + /// Gets or Sets ObjectItemsNullable + /// + [JsonPropertyName("object_items_nullable")] + public Dictionary ObjectItemsNullable { get { return this.ObjectItemsNullableOption; } set { this.ObjectItemsNullableOption = new Option>(value); } } + + /// + /// Used to track the state of ObjectNullableProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> ObjectNullablePropOption { get; private set; } + + /// + /// Gets or Sets ObjectNullableProp + /// + [JsonPropertyName("object_nullable_prop")] + public Dictionary ObjectNullableProp { get { return this.ObjectNullablePropOption; } set { this.ObjectNullablePropOption = new Option>(value); } } + + /// + /// Used to track the state of StringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringPropOption { get; private set; } + + /// + /// Gets or Sets StringProp + /// + [JsonPropertyName("string_prop")] + public string StringProp { get { return this.StringPropOption; } set { this.StringPropOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableClass {\n"); + sb.Append(" ArrayAndItemsNullableProp: ").Append(ArrayAndItemsNullableProp).Append("\n"); + sb.Append(" ArrayItemsNullable: ").Append(ArrayItemsNullable).Append("\n"); + sb.Append(" ArrayNullableProp: ").Append(ArrayNullableProp).Append("\n"); + sb.Append(" BooleanProp: ").Append(BooleanProp).Append("\n"); + sb.Append(" DateProp: ").Append(DateProp).Append("\n"); + sb.Append(" DatetimeProp: ").Append(DatetimeProp).Append("\n"); + sb.Append(" IntegerProp: ").Append(IntegerProp).Append("\n"); + sb.Append(" NumberProp: ").Append(NumberProp).Append("\n"); + sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); + sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); + sb.Append(" StringProp: ").Append(StringProp).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateProp + /// + public static string DatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize DatetimeProp + /// + public static string DatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> arrayAndItemsNullableProp = default; + Option> arrayItemsNullable = default; + Option> arrayNullableProp = default; + Option booleanProp = default; + Option dateProp = default; + Option datetimeProp = default; + Option integerProp = default; + Option numberProp = default; + Option> objectAndItemsNullableProp = default; + Option> objectItemsNullable = default; + Option> objectNullableProp = default; + Option stringProp = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "array_and_items_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "array_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + arrayNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + booleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + dateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + datetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + integerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "number_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + numberProp = new Option(utf8JsonReader.GetDecimal()); + break; + case "object_and_items_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectAndItemsNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_items_nullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectItemsNullable = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "object_nullable_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectNullableProp = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "string_prop": + stringProp = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null) + throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass."); + + if (objectItemsNullable.IsSet && objectItemsNullable.Value == null) + throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass."); + + return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, nullableClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + { + if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass."); + + if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null) + throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass."); + + if (nullableClass.ArrayAndItemsNullablePropOption.IsSet) + if (nullableClass.ArrayAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("array_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_and_items_nullable_prop"); + if (nullableClass.ArrayItemsNullableOption.IsSet) + { + writer.WritePropertyName("array_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ArrayItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ArrayNullablePropOption.IsSet) + if (nullableClass.ArrayNullablePropOption.Value != null) + { + writer.WritePropertyName("array_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ArrayNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("array_nullable_prop"); + if (nullableClass.BooleanPropOption.IsSet) + if (nullableClass.BooleanPropOption.Value != null) + writer.WriteBoolean("boolean_prop", nullableClass.BooleanPropOption.Value.Value); + else + writer.WriteNull("boolean_prop"); + + if (nullableClass.DatePropOption.IsSet) + if (nullableClass.DatePropOption.Value != null) + writer.WriteString("date_prop", nullableClass.DatePropOption.Value.Value.ToString(DatePropFormat)); + else + writer.WriteNull("date_prop"); + + if (nullableClass.DatetimePropOption.IsSet) + if (nullableClass.DatetimePropOption.Value != null) + writer.WriteString("datetime_prop", nullableClass.DatetimePropOption.Value.Value.ToString(DatetimePropFormat)); + else + writer.WriteNull("datetime_prop"); + + if (nullableClass.IntegerPropOption.IsSet) + if (nullableClass.IntegerPropOption.Value != null) + writer.WriteNumber("integer_prop", nullableClass.IntegerPropOption.Value.Value); + else + writer.WriteNull("integer_prop"); + + if (nullableClass.NumberPropOption.IsSet) + if (nullableClass.NumberPropOption.Value != null) + writer.WriteNumber("number_prop", nullableClass.NumberPropOption.Value.Value); + else + writer.WriteNull("number_prop"); + + if (nullableClass.ObjectAndItemsNullablePropOption.IsSet) + if (nullableClass.ObjectAndItemsNullablePropOption.Value != null) + { + writer.WritePropertyName("object_and_items_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectAndItemsNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_and_items_nullable_prop"); + if (nullableClass.ObjectItemsNullableOption.IsSet) + { + writer.WritePropertyName("object_items_nullable"); + JsonSerializer.Serialize(writer, nullableClass.ObjectItemsNullable, jsonSerializerOptions); + } + if (nullableClass.ObjectNullablePropOption.IsSet) + if (nullableClass.ObjectNullablePropOption.Value != null) + { + writer.WritePropertyName("object_nullable_prop"); + JsonSerializer.Serialize(writer, nullableClass.ObjectNullableProp, jsonSerializerOptions); + } + else + writer.WriteNull("object_nullable_prop"); + if (nullableClass.StringPropOption.IsSet) + if (nullableClass.StringPropOption.Value != null) + writer.WriteString("string_prop", nullableClass.StringProp); + else + writer.WriteNull("string_prop"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs new file mode 100644 index 000000000000..ef86eb595aca --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -0,0 +1,173 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NullableGuidClass + /// + public partial class NullableGuidClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// uuid + [JsonConstructor] + public NullableGuidClass(Option uuid = default) + { + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("uuid")] + public Guid? Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableGuidClass {\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableGuidClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableGuidClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + uuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + return new NullableGuidClass(uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + { + if (nullableGuidClass.UuidOption.IsSet) + if (nullableGuidClass.UuidOption.Value != null) + writer.WriteString("uuid", nullableGuidClass.UuidOption.Value.Value); + else + writer.WriteNull("uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs new file mode 100644 index 000000000000..10061a2c228b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// The value may be a shape or the 'null' value. The 'nullable' attribute was introduced in OAS schema >= 3.0 and has been deprecated in OAS schema >= 3.1. + /// + public partial class NullableShape : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public NullableShape(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public NullableShape(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NullableShape {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NullableShapeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class NullableShape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); + + if (quadrilateral != null) + return new NullableShape(quadrilateral); + + if (triangle != null) + return new NullableShape(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (nullableShape.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); + } + + if (nullableShape.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, nullableShape, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs new file mode 100644 index 000000000000..2b602ec80d78 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -0,0 +1,172 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NumberOnly + /// + public partial class NumberOnly : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// justNumber + [JsonConstructor] + public NumberOnly(Option justNumber = default) + { + JustNumberOption = justNumber; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of JustNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option JustNumberOption { get; private set; } + + /// + /// Gets or Sets JustNumber + /// + [JsonPropertyName("JustNumber")] + public decimal? JustNumber { get { return this.JustNumberOption; } set { this.JustNumberOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NumberOnly {\n"); + sb.Append(" JustNumber: ").Append(JustNumber).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NumberOnlyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option justNumber = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "JustNumber": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + justNumber = new Option(utf8JsonReader.GetDecimal()); + break; + default: + break; + } + } + } + + if (justNumber.IsSet && justNumber.Value == null) + throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly."); + + return new NumberOnly(justNumber); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, numberOnly, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + { + if (numberOnly.JustNumberOption.IsSet) + writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs new file mode 100644 index 000000000000..5cc97e836da0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -0,0 +1,268 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ObjectWithDeprecatedFields + /// + public partial class ObjectWithDeprecatedFields : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bars + /// deprecatedRef + /// id + /// uuid + [JsonConstructor] + public ObjectWithDeprecatedFields(Option> bars = default, Option deprecatedRef = default, Option id = default, Option uuid = default) + { + BarsOption = bars; + DeprecatedRefOption = deprecatedRef; + IdOption = id; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bars + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> BarsOption { get; private set; } + + /// + /// Gets or Sets Bars + /// + [JsonPropertyName("bars")] + [Obsolete] + public List Bars { get { return this.BarsOption; } set { this.BarsOption = new Option>(value); } } + + /// + /// Used to track the state of DeprecatedRef + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DeprecatedRefOption { get; private set; } + + /// + /// Gets or Sets DeprecatedRef + /// + [JsonPropertyName("deprecatedRef")] + [Obsolete] + public DeprecatedObject DeprecatedRef { get { return this.DeprecatedRefOption; } set { this.DeprecatedRefOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + [Obsolete] + public decimal? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Gets or Sets Uuid + /// + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ObjectWithDeprecatedFields {\n"); + sb.Append(" Bars: ").Append(Bars).Append("\n"); + sb.Append(" DeprecatedRef: ").Append(DeprecatedRef).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ObjectWithDeprecatedFieldsJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> bars = default; + Option deprecatedRef = default; + Option id = default; + Option uuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bars": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + bars = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "deprecatedRef": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + deprecatedRef = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetDecimal()); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bars.IsSet && bars.Value == null) + throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (deprecatedRef.IsSet && deprecatedRef.Value == null) + throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields."); + + return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + { + if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null) + throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields."); + + if (objectWithDeprecatedFields.BarsOption.IsSet) + { + writer.WritePropertyName("bars"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.Bars, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet) + { + writer.WritePropertyName("deprecatedRef"); + JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions); + } + if (objectWithDeprecatedFields.IdOption.IsSet) + writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value.Value); + + if (objectWithDeprecatedFields.UuidOption.IsSet) + writer.WriteString("uuid", objectWithDeprecatedFields.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs new file mode 100644 index 000000000000..0f4f13f311b0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs @@ -0,0 +1,157 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// OneOfString + /// + public partial class OneOfString : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + internal OneOfString(string @string) + { + String = @string; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class OneOfString {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OneOfStringJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override OneOfString Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + string varString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (varString != null) + return new OneOfString(varString); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, oneOfString, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs new file mode 100644 index 000000000000..8d0ff1212132 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Order.cs @@ -0,0 +1,396 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Order + /// + public partial class Order : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// complete (default to false) + /// id + /// petId + /// quantity + /// shipDate + /// Order Status + [JsonConstructor] + public Order(Option complete = default, Option id = default, Option petId = default, Option quantity = default, Option shipDate = default, Option status = default) + { + CompleteOption = complete; + IdOption = id; + PetIdOption = petId; + QuantityOption = quantity; + ShipDateOption = shipDate; + StatusOption = status; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Order Status + /// + /// Order Status + public enum StatusEnum + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Returns a + /// + /// + /// + /// + public static StatusEnum StatusEnumFromString(string value) + { + if (value.Equals("placed")) + return StatusEnum.Placed; + + if (value.Equals("approved")) + return StatusEnum.Approved; + + if (value.Equals("delivered")) + return StatusEnum.Delivered; + + throw new NotImplementedException($"Could not convert value to type StatusEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static StatusEnum? StatusEnumFromStringOrDefault(string value) + { + if (value.Equals("placed")) + return StatusEnum.Placed; + + if (value.Equals("approved")) + return StatusEnum.Approved; + + if (value.Equals("delivered")) + return StatusEnum.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string StatusEnumToJsonValue(StatusEnum? value) + { + if (value == StatusEnum.Placed) + return "placed"; + + if (value == StatusEnum.Approved) + return "approved"; + + if (value == StatusEnum.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + + /// + /// Order Status + /// + /// Order Status + [JsonPropertyName("status")] + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } + + /// + /// Used to track the state of Complete + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CompleteOption { get; private set; } + + /// + /// Gets or Sets Complete + /// + [JsonPropertyName("complete")] + public bool? Complete { get { return this.CompleteOption; } set { this.CompleteOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of PetId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PetIdOption { get; private set; } + + /// + /// Gets or Sets PetId + /// + [JsonPropertyName("petId")] + public long? PetId { get { return this.PetIdOption; } set { this.PetIdOption = new Option(value); } } + + /// + /// Used to track the state of Quantity + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option QuantityOption { get; private set; } + + /// + /// Gets or Sets Quantity + /// + [JsonPropertyName("quantity")] + public int? Quantity { get { return this.QuantityOption; } set { this.QuantityOption = new Option(value); } } + + /// + /// Used to track the state of ShipDate + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ShipDateOption { get; private set; } + + /// + /// Gets or Sets ShipDate + /// + /// 2020-02-02T20:20:20.000222Z + [JsonPropertyName("shipDate")] + public DateTime? ShipDate { get { return this.ShipDateOption; } set { this.ShipDateOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Order {\n"); + sb.Append(" Complete: ").Append(Complete).Append("\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(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OrderJsonConverter : JsonConverter + { + /// + /// The format to use to serialize ShipDate + /// + public static string ShipDateFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option complete = default; + Option id = default; + Option petId = default; + Option quantity = default; + Option shipDate = default; + Option status = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "complete": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + complete = new Option(utf8JsonReader.GetBoolean()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "petId": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + petId = new Option(utf8JsonReader.GetInt64()); + break; + case "quantity": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + quantity = new Option(utf8JsonReader.GetInt32()); + break; + case "shipDate": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + shipDate = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "status": + string statusRawValue = utf8JsonReader.GetString(); + if (statusRawValue != null) + status = new Option(Order.StatusEnumFromStringOrDefault(statusRawValue)); + break; + default: + break; + } + } + } + + if (complete.IsSet && complete.Value == null) + throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order."); + + if (petId.IsSet && petId.Value == null) + throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order."); + + if (quantity.IsSet && quantity.Value == null) + throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order."); + + if (shipDate.IsSet && shipDate.Value == null) + throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order."); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order."); + + return new Order(complete, id, petId, quantity, shipDate, status); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, order, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + { + if (order.CompleteOption.IsSet) + writer.WriteBoolean("complete", order.CompleteOption.Value.Value); + + if (order.IdOption.IsSet) + writer.WriteNumber("id", order.IdOption.Value.Value); + + if (order.PetIdOption.IsSet) + writer.WriteNumber("petId", order.PetIdOption.Value.Value); + + if (order.QuantityOption.IsSet) + writer.WriteNumber("quantity", order.QuantityOption.Value.Value); + + if (order.ShipDateOption.IsSet) + writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat)); + + var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value.Value); + writer.WriteString("status", statusRawValue); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs new file mode 100644 index 000000000000..bb1af3218659 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -0,0 +1,228 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// OuterComposite + /// + public partial class OuterComposite : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// myBoolean + /// myNumber + /// myString + [JsonConstructor] + public OuterComposite(Option myBoolean = default, Option myNumber = default, Option myString = default) + { + MyBooleanOption = myBoolean; + MyNumberOption = myNumber; + MyStringOption = myString; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of MyBoolean + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyBooleanOption { get; private set; } + + /// + /// Gets or Sets MyBoolean + /// + [JsonPropertyName("my_boolean")] + public bool? MyBoolean { get { return this.MyBooleanOption; } set { this.MyBooleanOption = new Option(value); } } + + /// + /// Used to track the state of MyNumber + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyNumberOption { get; private set; } + + /// + /// Gets or Sets MyNumber + /// + [JsonPropertyName("my_number")] + public decimal? MyNumber { get { return this.MyNumberOption; } set { this.MyNumberOption = new Option(value); } } + + /// + /// Used to track the state of MyString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MyStringOption { get; private set; } + + /// + /// Gets or Sets MyString + /// + [JsonPropertyName("my_string")] + public string MyString { get { return this.MyStringOption; } set { this.MyStringOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class OuterComposite {\n"); + sb.Append(" MyBoolean: ").Append(MyBoolean).Append("\n"); + sb.Append(" MyNumber: ").Append(MyNumber).Append("\n"); + sb.Append(" MyString: ").Append(MyString).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class OuterCompositeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option myBoolean = default; + Option myNumber = default; + Option myString = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "my_boolean": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + myBoolean = new Option(utf8JsonReader.GetBoolean()); + break; + case "my_number": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + myNumber = new Option(utf8JsonReader.GetDecimal()); + break; + case "my_string": + myString = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (myBoolean.IsSet && myBoolean.Value == null) + throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite."); + + if (myNumber.IsSet && myNumber.Value == null) + throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite."); + + if (myString.IsSet && myString.Value == null) + throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite."); + + return new OuterComposite(myBoolean, myNumber, myString); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, outerComposite, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + { + if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null) + throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite."); + + if (outerComposite.MyBooleanOption.IsSet) + writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value.Value); + + if (outerComposite.MyNumberOption.IsSet) + writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value.Value); + + if (outerComposite.MyStringOption.IsSet) + writer.WriteString("my_string", outerComposite.MyString); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnum.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnum.cs new file mode 100644 index 000000000000..47bb6793c6ac --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnum.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnum + /// + public enum OuterEnum + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnum FromString(string value) + { + if (value.Equals("placed")) + return OuterEnum.Placed; + + if (value.Equals("approved")) + return OuterEnum.Approved; + + if (value.Equals("delivered")) + return OuterEnum.Delivered; + + throw new NotImplementedException($"Could not convert value to type OuterEnum: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnum? FromStringOrDefault(string value) + { + if (value.Equals("placed")) + return OuterEnum.Placed; + + if (value.Equals("approved")) + return OuterEnum.Approved; + + if (value.Equals("delivered")) + return OuterEnum.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnum value) + { + if (value == OuterEnum.Placed) + return "placed"; + + if (value == OuterEnum.Approved) + return "approved"; + + if (value == OuterEnum.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnum? result = rawValue == null + ? null + : OuterEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnum to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnum outerEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnum.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnum from the Json object + /// + /// + /// + /// + /// + public override OuterEnum? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnum? result = rawValue == null + ? null + : OuterEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnum? outerEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnum?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs new file mode 100644 index 000000000000..136fb4c54c4e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumDefaultValue.cs @@ -0,0 +1,188 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumDefaultValue + /// + public enum OuterEnumDefaultValue + { + /// + /// Enum Placed for value: placed + /// + Placed = 1, + + /// + /// Enum Approved for value: approved + /// + Approved = 2, + + /// + /// Enum Delivered for value: delivered + /// + Delivered = 3 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumDefaultValueValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumDefaultValue FromString(string value) + { + if (value.Equals("placed")) + return OuterEnumDefaultValue.Placed; + + if (value.Equals("approved")) + return OuterEnumDefaultValue.Approved; + + if (value.Equals("delivered")) + return OuterEnumDefaultValue.Delivered; + + throw new NotImplementedException($"Could not convert value to type OuterEnumDefaultValue: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumDefaultValue? FromStringOrDefault(string value) + { + if (value.Equals("placed")) + return OuterEnumDefaultValue.Placed; + + if (value.Equals("approved")) + return OuterEnumDefaultValue.Approved; + + if (value.Equals("delivered")) + return OuterEnumDefaultValue.Delivered; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnumDefaultValue value) + { + if (value == OuterEnumDefaultValue.Placed) + return "placed"; + + if (value == OuterEnumDefaultValue.Approved) + return "approved"; + + if (value == OuterEnumDefaultValue.Delivered) + return "delivered"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumDefaultValueJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumDefaultValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumDefaultValue? result = rawValue == null + ? null + : OuterEnumDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumDefaultValue to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumDefaultValue outerEnumDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumDefaultValue.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumDefaultValueNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumDefaultValue from the Json object + /// + /// + /// + /// + /// + public override OuterEnumDefaultValue? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumDefaultValue? result = rawValue == null + ? null + : OuterEnumDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumDefaultValue? outerEnumDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumDefaultValue?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumInteger.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumInteger.cs new file mode 100644 index 000000000000..2ed4f18a657e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumInteger.cs @@ -0,0 +1,179 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumInteger + /// + public enum OuterEnumInteger + { + /// + /// Enum NUMBER_0 for value: 0 + /// + NUMBER_0 = 0, + + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumIntegerValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumInteger FromString(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumInteger.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumInteger.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumInteger.NUMBER_2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumInteger: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumInteger? FromStringOrDefault(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumInteger.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumInteger.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumInteger.NUMBER_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(OuterEnumInteger value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumIntegerJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumInteger? result = rawValue == null + ? null + : OuterEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumInteger to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumInteger outerEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumInteger.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumIntegerNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumInteger from the Json object + /// + /// + /// + /// + /// + public override OuterEnumInteger? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumInteger? result = rawValue == null + ? null + : OuterEnumIntegerValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumInteger? outerEnumInteger, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumInteger?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs new file mode 100644 index 000000000000..c6a470cc64d1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumIntegerDefaultValue.cs @@ -0,0 +1,179 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines OuterEnumIntegerDefaultValue + /// + public enum OuterEnumIntegerDefaultValue + { + /// + /// Enum NUMBER_0 for value: 0 + /// + NUMBER_0 = 0, + + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumIntegerDefaultValueValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumIntegerDefaultValue FromString(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumIntegerDefaultValue: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumIntegerDefaultValue? FromStringOrDefault(string value) + { + if (value.Equals((0).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_0; + + if (value.Equals((1).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_1; + + if (value.Equals((2).ToString())) + return OuterEnumIntegerDefaultValue.NUMBER_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static int ToJsonValue(OuterEnumIntegerDefaultValue value) + { + return (int) value; + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumIntegerDefaultValueJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumIntegerDefaultValue Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumIntegerDefaultValue? result = rawValue == null + ? null + : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumIntegerDefaultValue to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumIntegerDefaultValue.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumIntegerDefaultValueNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumIntegerDefaultValue from the Json object + /// + /// + /// + /// + /// + public override OuterEnumIntegerDefaultValue? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumIntegerDefaultValue? result = rawValue == null + ? null + : OuterEnumIntegerDefaultValueValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumIntegerDefaultValue?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumTest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumTest.cs new file mode 100644 index 000000000000..a2e789f2edef --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/OuterEnumTest.cs @@ -0,0 +1,258 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines Outer_Enum_Test + /// + public enum OuterEnumTest + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Converts to and from the JSON value + /// + public static class OuterEnumTestValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumTest FromString(string value) + { + if (value.Equals("UPPER")) + return OuterEnumTest.UPPER; + + if (value.Equals("lower")) + return OuterEnumTest.Lower; + + if (value.Equals("")) + return OuterEnumTest.Empty; + + if (value.Equals("Value\twith tab")) + return OuterEnumTest.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return OuterEnumTest.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return OuterEnumTest.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return OuterEnumTest.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return OuterEnumTest.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type OuterEnumTest: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static OuterEnumTest? FromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return OuterEnumTest.UPPER; + + if (value.Equals("lower")) + return OuterEnumTest.Lower; + + if (value.Equals("")) + return OuterEnumTest.Empty; + + if (value.Equals("Value\twith tab")) + return OuterEnumTest.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return OuterEnumTest.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return OuterEnumTest.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return OuterEnumTest.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return OuterEnumTest.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(OuterEnumTest value) + { + if (value == OuterEnumTest.UPPER) + return "UPPER"; + + if (value == OuterEnumTest.Lower) + return "lower"; + + if (value == OuterEnumTest.Empty) + return ""; + + if (value == OuterEnumTest.ValuewithTab) + return "Value\twith tab"; + + if (value == OuterEnumTest.ValueWithQuote) + return "Value with \" quote"; + + if (value == OuterEnumTest.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == OuterEnumTest.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == OuterEnumTest.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class OuterEnumTestJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override OuterEnumTest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumTest? result = rawValue == null + ? null + : OuterEnumTestValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the OuterEnumTest to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumTest outerEnumTest, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumTest.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class OuterEnumTestNullableJsonConverter : JsonConverter + { + /// + /// Returns a OuterEnumTest from the Json object + /// + /// + /// + /// + /// + public override OuterEnumTest? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + OuterEnumTest? result = rawValue == null + ? null + : OuterEnumTestValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, OuterEnumTest? outerEnumTest, JsonSerializerOptions options) + { + writer.WriteStringValue(outerEnumTest?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs new file mode 100644 index 000000000000..5d1cab769fa8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs @@ -0,0 +1,158 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ParentPet + /// + public partial class ParentPet : GrandparentAnimal, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public ParentPet() : base() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string PetType { get; } = "ParentPet"; + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ParentPet {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class ParentPetJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option petType = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "pet_type"); + + if (discriminator != null && discriminator.Equals("ChildCat")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "pet_type": + petType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!petType.IsSet) + throw new ArgumentException("Property is required for class ParentPet.", nameof(petType)); + + if (petType.IsSet && petType.Value == null) + throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); + + return new ParentPet(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, parentPet, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("pet_type", parentPet.PetType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs new file mode 100644 index 000000000000..ec63640215f3 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pet.cs @@ -0,0 +1,396 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Pet + /// + public partial class Pet : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + /// photoUrls + /// category + /// id + /// pet status in the store + /// tags + [JsonConstructor] + public Pet(string name, List photoUrls, Option category = default, Option id = default, Option status = default, Option> tags = default) + { + Name = name; + PhotoUrls = photoUrls; + CategoryOption = category; + IdOption = id; + StatusOption = status; + TagsOption = tags; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// pet status in the store + /// + /// pet status in the store + public enum StatusEnum + { + /// + /// Enum Available for value: available + /// + Available = 1, + + /// + /// Enum Pending for value: pending + /// + Pending = 2, + + /// + /// Enum Sold for value: sold + /// + Sold = 3 + } + + /// + /// Returns a + /// + /// + /// + /// + public static StatusEnum StatusEnumFromString(string value) + { + if (value.Equals("available")) + return StatusEnum.Available; + + if (value.Equals("pending")) + return StatusEnum.Pending; + + if (value.Equals("sold")) + return StatusEnum.Sold; + + throw new NotImplementedException($"Could not convert value to type StatusEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static StatusEnum? StatusEnumFromStringOrDefault(string value) + { + if (value.Equals("available")) + return StatusEnum.Available; + + if (value.Equals("pending")) + return StatusEnum.Pending; + + if (value.Equals("sold")) + return StatusEnum.Sold; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string StatusEnumToJsonValue(StatusEnum? value) + { + if (value == StatusEnum.Available) + return "available"; + + if (value == StatusEnum.Pending) + return "pending"; + + if (value == StatusEnum.Sold) + return "sold"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of Status + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StatusOption { get; private set; } + + /// + /// pet status in the store + /// + /// pet status in the store + [JsonPropertyName("status")] + public StatusEnum? Status { get { return this.StatusOption; } set { this.StatusOption = new Option(value); } } + + /// + /// Gets or Sets Name + /// + /// doggie + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [JsonPropertyName("photoUrls")] + public List PhotoUrls { get; set; } + + /// + /// Used to track the state of Category + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option CategoryOption { get; private set; } + + /// + /// Gets or Sets Category + /// + [JsonPropertyName("category")] + public Category Category { get { return this.CategoryOption; } set { this.CategoryOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Tags + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TagsOption { get; private set; } + + /// + /// Gets or Sets Tags + /// + [JsonPropertyName("tags")] + public List Tags { get { return this.TagsOption; } set { this.TagsOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Pet {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PetJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + Option> photoUrls = default; + Option category = default; + Option id = default; + Option status = default; + Option> tags = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + case "photoUrls": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + photoUrls = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "category": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + category = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "status": + string statusRawValue = utf8JsonReader.GetString(); + if (statusRawValue != null) + status = new Option(Pet.StatusEnumFromStringOrDefault(statusRawValue)); + break; + case "tags": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + tags = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (!name.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(name)); + + if (!photoUrls.IsSet) + throw new ArgumentException("Property is required for class Pet.", nameof(photoUrls)); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Pet."); + + if (photoUrls.IsSet && photoUrls.Value == null) + throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet."); + + if (category.IsSet && category.Value == null) + throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet."); + + if (status.IsSet && status.Value == null) + throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet."); + + if (tags.IsSet && tags.Value == null) + throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet."); + + return new Pet(name.Value, photoUrls.Value, category, id, status, tags); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, pet, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + { + if (pet.Name == null) + throw new ArgumentNullException(nameof(pet.Name), "Property is required for class Pet."); + + if (pet.PhotoUrls == null) + throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet."); + + if (pet.CategoryOption.IsSet && pet.Category == null) + throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet."); + + if (pet.TagsOption.IsSet && pet.Tags == null) + throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet."); + + writer.WriteString("name", pet.Name); + + writer.WritePropertyName("photoUrls"); + JsonSerializer.Serialize(writer, pet.PhotoUrls, jsonSerializerOptions); + if (pet.CategoryOption.IsSet) + { + writer.WritePropertyName("category"); + JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions); + } + if (pet.IdOption.IsSet) + writer.WriteNumber("id", pet.IdOption.Value.Value); + + var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value.Value); + writer.WriteString("status", statusRawValue); + if (pet.TagsOption.IsSet) + { + writer.WritePropertyName("tags"); + JsonSerializer.Serialize(writer, pet.Tags, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs new file mode 100644 index 000000000000..19e395f1de47 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Pig + /// + public partial class Pig : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Pig(BasquePig basquePig) + { + BasquePig = basquePig; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Pig(DanishPig danishPig) + { + DanishPig = danishPig; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets BasquePig + /// + public BasquePig BasquePig { get; set; } + + /// + /// Gets or Sets DanishPig + /// + public DanishPig DanishPig { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Pig {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PigJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + + BasquePig basquePig = null; + DanishPig danishPig = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("className")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("BasquePig")) + { + Utf8JsonReader utf8JsonReaderBasquePig = utf8JsonReader; + basquePig = JsonSerializer.Deserialize(ref utf8JsonReaderBasquePig, jsonSerializerOptions); + } + if (discriminator.Equals("DanishPig")) + { + Utf8JsonReader utf8JsonReaderDanishPig = utf8JsonReader; + danishPig = JsonSerializer.Deserialize(ref utf8JsonReaderDanishPig, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Pig.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); + + if (basquePig != null) + return new Pig(basquePig); + + if (danishPig != null) + return new Pig(danishPig); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (pig.BasquePig != null) { + BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); + } + + if (pig.DanishPig != null) { + DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); + } + + WriteProperties(writer, pig, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs new file mode 100644 index 000000000000..30edd0b77d2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -0,0 +1,239 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// PolymorphicProperty + /// + public partial class PolymorphicProperty : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(Object @object) + { + Object = @object; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + internal PolymorphicProperty(List list) + { + List = list; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Object + /// + public Object Object { get; set; } + + /// + /// Gets or Sets List + /// + public List List { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class PolymorphicProperty {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class PolymorphicPropertyJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override PolymorphicProperty Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + bool? varBool = default; + string varString = default; + Object varObject = default; + List list = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderObject = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderObject, jsonSerializerOptions, out varObject); + + Utf8JsonReader utf8JsonReaderList = utf8JsonReader; + ClientUtils.TryDeserialize>(ref utf8JsonReaderList, jsonSerializerOptions, out list); + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + default: + break; + } + } + } + + if (varBool != null) + return new PolymorphicProperty(varBool.Value); + + if (varString != null) + return new PolymorphicProperty(varString); + + if (varObject != null) + return new PolymorphicProperty(varObject); + + if (list != null) + return new PolymorphicProperty(list); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs new file mode 100644 index 000000000000..3d333d7958fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Quadrilateral + /// + public partial class Quadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) + { + SimpleQuadrilateral = simpleQuadrilateral; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) + { + ComplexQuadrilateral = complexQuadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets SimpleQuadrilateral + /// + public SimpleQuadrilateral SimpleQuadrilateral { get; set; } + + /// + /// Gets or Sets ComplexQuadrilateral + /// + public ComplexQuadrilateral ComplexQuadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Quadrilateral {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class QuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + + ComplexQuadrilateral complexQuadrilateral = null; + SimpleQuadrilateral simpleQuadrilateral = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("quadrilateralType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("ComplexQuadrilateral")) + { + Utf8JsonReader utf8JsonReaderComplexQuadrilateral = utf8JsonReader; + complexQuadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderComplexQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("SimpleQuadrilateral")) + { + Utf8JsonReader utf8JsonReaderSimpleQuadrilateral = utf8JsonReader; + simpleQuadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderSimpleQuadrilateral, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class Quadrilateral.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); + + if (complexQuadrilateral != null) + return new Quadrilateral(complexQuadrilateral); + + if (simpleQuadrilateral != null) + return new Quadrilateral(simpleQuadrilateral); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (quadrilateral.SimpleQuadrilateral != null) { + SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + } + + if (quadrilateral.ComplexQuadrilateral != null) { + ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, quadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs new file mode 100644 index 000000000000..610005a05408 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// QuadrilateralInterface + /// + public partial class QuadrilateralInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + [JsonConstructor] + public QuadrilateralInterface(string quadrilateralType) + { + QuadrilateralType = quadrilateralType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class QuadrilateralInterface {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class QuadrilateralInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override QuadrilateralInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class QuadrilateralInterface.", nameof(quadrilateralType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class QuadrilateralInterface."); + + return new QuadrilateralInterface(quadrilateralType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (quadrilateralInterface.QuadrilateralType == null) + throw new ArgumentNullException(nameof(quadrilateralInterface.QuadrilateralType), "Property is required for class QuadrilateralInterface."); + + writer.WriteString("quadrilateralType", quadrilateralInterface.QuadrilateralType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs new file mode 100644 index 000000000000..87358abb827d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -0,0 +1,241 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ReadOnlyFirst + /// + public partial class ReadOnlyFirst : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// bar + /// baz + [JsonConstructor] + public ReadOnlyFirst(Option bar = default, Option baz = default) + { + BarOption = bar; + BazOption = baz; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Bar + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BarOption { get; } + + /// + /// Gets or Sets Bar + /// + [JsonPropertyName("bar")] + public string Bar { get { return this.BarOption; } } + + /// + /// Used to track the state of Baz + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BazOption { get; private set; } + + /// + /// Gets or Sets Baz + /// + [JsonPropertyName("baz")] + public string Baz { get { return this.BazOption; } set { this.BazOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ReadOnlyFirst {\n"); + sb.Append(" Bar: ").Append(Bar).Append("\n"); + sb.Append(" Baz: ").Append(Baz).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as ReadOnlyFirst).AreEqual; + } + + /// + /// Returns true if ReadOnlyFirst instances are equal + /// + /// Instance of ReadOnlyFirst to be compared + /// Boolean + public bool Equals(ReadOnlyFirst input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (Bar != null) + hashCode = (hashCode * 59) + Bar.GetHashCode(); + + hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); + + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ReadOnlyFirstJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option bar = default; + Option baz = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "bar": + bar = new Option(utf8JsonReader.GetString()); + break; + case "baz": + baz = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (bar.IsSet && bar.Value == null) + throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst."); + + if (baz.IsSet && baz.Value == null) + throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst."); + + return new ReadOnlyFirst(bar, baz); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + { + if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null) + throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst."); + + if (readOnlyFirst.BarOption.IsSet) + writer.WriteString("bar", readOnlyFirst.Bar); + + if (readOnlyFirst.BazOption.IsSet) + writer.WriteString("baz", readOnlyFirst.Baz); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs new file mode 100644 index 000000000000..dda8b3ba8a84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -0,0 +1,2378 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RequiredClass + /// + public partial class RequiredClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// requiredNotNullableDateProp + /// requiredNotnullableArrayOfString + /// requiredNotnullableBooleanProp + /// requiredNotnullableDatetimeProp + /// requiredNotnullableEnumInteger + /// requiredNotnullableEnumIntegerOnly + /// requiredNotnullableEnumString + /// requiredNotnullableOuterEnumDefaultValue + /// requiredNotnullableStringProp + /// requiredNotnullableUuid + /// requiredNotnullableintegerProp + /// notRequiredNotnullableDateProp + /// notRequiredNotnullableintegerProp + /// notRequiredNullableDateProp + /// notRequiredNullableIntegerProp + /// notrequiredNotnullableArrayOfString + /// notrequiredNotnullableBooleanProp + /// notrequiredNotnullableDatetimeProp + /// notrequiredNotnullableEnumInteger + /// notrequiredNotnullableEnumIntegerOnly + /// notrequiredNotnullableEnumString + /// notrequiredNotnullableOuterEnumDefaultValue + /// notrequiredNotnullableStringProp + /// notrequiredNotnullableUuid + /// notrequiredNullableArrayOfString + /// notrequiredNullableBooleanProp + /// notrequiredNullableDatetimeProp + /// notrequiredNullableEnumInteger + /// notrequiredNullableEnumIntegerOnly + /// notrequiredNullableEnumString + /// notrequiredNullableOuterEnumDefaultValue + /// notrequiredNullableStringProp + /// notrequiredNullableUuid + /// requiredNullableArrayOfString + /// requiredNullableBooleanProp + /// requiredNullableDateProp + /// requiredNullableDatetimeProp + /// requiredNullableEnumInteger + /// requiredNullableEnumIntegerOnly + /// requiredNullableEnumString + /// requiredNullableIntegerProp + /// requiredNullableOuterEnumDefaultValue + /// requiredNullableStringProp + /// requiredNullableUuid + [JsonConstructor] + public RequiredClass(DateTime requiredNotNullableDateProp, List requiredNotnullableArrayOfString, bool requiredNotnullableBooleanProp, DateTime requiredNotnullableDatetimeProp, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue, string requiredNotnullableStringProp, Guid requiredNotnullableUuid, int requiredNotnullableintegerProp, Option notRequiredNotnullableDateProp = default, Option notRequiredNotnullableintegerProp = default, Option notRequiredNullableDateProp = default, Option notRequiredNullableIntegerProp = default, Option> notrequiredNotnullableArrayOfString = default, Option notrequiredNotnullableBooleanProp = default, Option notrequiredNotnullableDatetimeProp = default, Option notrequiredNotnullableEnumInteger = default, Option notrequiredNotnullableEnumIntegerOnly = default, Option notrequiredNotnullableEnumString = default, Option notrequiredNotnullableOuterEnumDefaultValue = default, Option notrequiredNotnullableStringProp = default, Option notrequiredNotnullableUuid = default, Option> notrequiredNullableArrayOfString = default, Option notrequiredNullableBooleanProp = default, Option notrequiredNullableDatetimeProp = default, Option notrequiredNullableEnumInteger = default, Option notrequiredNullableEnumIntegerOnly = default, Option notrequiredNullableEnumString = default, Option notrequiredNullableOuterEnumDefaultValue = default, Option notrequiredNullableStringProp = default, Option notrequiredNullableUuid = default, List requiredNullableArrayOfString = default, bool? requiredNullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime? requiredNullableDatetimeProp = default, RequiredNullableEnumIntegerEnum? requiredNullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum? requiredNullableEnumIntegerOnly = default, RequiredNullableEnumStringEnum? requiredNullableEnumString = default, int? requiredNullableIntegerProp = default, OuterEnumDefaultValue? requiredNullableOuterEnumDefaultValue = default, string requiredNullableStringProp = default, Guid? requiredNullableUuid = default) + { + RequiredNotNullableDateProp = requiredNotNullableDateProp; + RequiredNotnullableArrayOfString = requiredNotnullableArrayOfString; + RequiredNotnullableBooleanProp = requiredNotnullableBooleanProp; + RequiredNotnullableDatetimeProp = requiredNotnullableDatetimeProp; + RequiredNotnullableEnumInteger = requiredNotnullableEnumInteger; + RequiredNotnullableEnumIntegerOnly = requiredNotnullableEnumIntegerOnly; + RequiredNotnullableEnumString = requiredNotnullableEnumString; + RequiredNotnullableOuterEnumDefaultValue = requiredNotnullableOuterEnumDefaultValue; + RequiredNotnullableStringProp = requiredNotnullableStringProp; + RequiredNotnullableUuid = requiredNotnullableUuid; + RequiredNotnullableintegerProp = requiredNotnullableintegerProp; + NotRequiredNotnullableDatePropOption = notRequiredNotnullableDateProp; + NotRequiredNotnullableintegerPropOption = notRequiredNotnullableintegerProp; + NotRequiredNullableDatePropOption = notRequiredNullableDateProp; + NotRequiredNullableIntegerPropOption = notRequiredNullableIntegerProp; + NotrequiredNotnullableArrayOfStringOption = notrequiredNotnullableArrayOfString; + NotrequiredNotnullableBooleanPropOption = notrequiredNotnullableBooleanProp; + NotrequiredNotnullableDatetimePropOption = notrequiredNotnullableDatetimeProp; + NotrequiredNotnullableEnumIntegerOption = notrequiredNotnullableEnumInteger; + NotrequiredNotnullableEnumIntegerOnlyOption = notrequiredNotnullableEnumIntegerOnly; + NotrequiredNotnullableEnumStringOption = notrequiredNotnullableEnumString; + NotrequiredNotnullableOuterEnumDefaultValueOption = notrequiredNotnullableOuterEnumDefaultValue; + NotrequiredNotnullableStringPropOption = notrequiredNotnullableStringProp; + NotrequiredNotnullableUuidOption = notrequiredNotnullableUuid; + NotrequiredNullableArrayOfStringOption = notrequiredNullableArrayOfString; + NotrequiredNullableBooleanPropOption = notrequiredNullableBooleanProp; + NotrequiredNullableDatetimePropOption = notrequiredNullableDatetimeProp; + NotrequiredNullableEnumIntegerOption = notrequiredNullableEnumInteger; + NotrequiredNullableEnumIntegerOnlyOption = notrequiredNullableEnumIntegerOnly; + NotrequiredNullableEnumStringOption = notrequiredNullableEnumString; + NotrequiredNullableOuterEnumDefaultValueOption = notrequiredNullableOuterEnumDefaultValue; + NotrequiredNullableStringPropOption = notrequiredNullableStringProp; + NotrequiredNullableUuidOption = notrequiredNullableUuid; + RequiredNullableArrayOfString = requiredNullableArrayOfString; + RequiredNullableBooleanProp = requiredNullableBooleanProp; + RequiredNullableDateProp = requiredNullableDateProp; + RequiredNullableDatetimeProp = requiredNullableDatetimeProp; + RequiredNullableEnumInteger = requiredNullableEnumInteger; + RequiredNullableEnumIntegerOnly = requiredNullableEnumIntegerOnly; + RequiredNullableEnumString = requiredNullableEnumString; + RequiredNullableIntegerProp = requiredNullableIntegerProp; + RequiredNullableOuterEnumDefaultValue = requiredNullableOuterEnumDefaultValue; + RequiredNullableStringProp = requiredNullableStringProp; + RequiredNullableUuid = requiredNullableUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines RequiredNotnullableEnumInteger + /// + public enum RequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerEnum? RequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerEnumToJsonValue(RequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumInteger + /// + [JsonPropertyName("required_notnullable_enum_integer")] + public RequiredNotnullableEnumIntegerEnum RequiredNotnullableEnumInteger { get; set; } + + /// + /// Defines RequiredNotnullableEnumIntegerOnly + /// + public enum RequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumIntegerOnlyEnum? RequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(RequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("required_notnullable_enum_integer_only")] + public RequiredNotnullableEnumIntegerOnlyEnum RequiredNotnullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNotnullableEnumString + /// + public enum RequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNotnullableEnumStringEnum RequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNotnullableEnumStringEnum? RequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNotnullableEnumStringEnumToJsonValue(RequiredNotnullableEnumStringEnum value) + { + if (value == RequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNotnullableEnumString + /// + [JsonPropertyName("required_notnullable_enum_string")] + public RequiredNotnullableEnumStringEnum RequiredNotnullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue RequiredNotnullableOuterEnumDefaultValue { get; set; } + + /// + /// Defines NotrequiredNotnullableEnumInteger + /// + public enum NotrequiredNotnullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum NotrequiredNotnullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNotnullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerEnumToJsonValue(NotrequiredNotnullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumInteger + /// + [JsonPropertyName("notrequired_notnullable_enum_integer")] + public NotrequiredNotnullableEnumIntegerEnum? NotrequiredNotnullableEnumInteger { get { return this.NotrequiredNotnullableEnumIntegerOption; } set { this.NotrequiredNotnullableEnumIntegerOption = new Option(value); } } + + /// + /// Defines NotrequiredNotnullableEnumIntegerOnly + /// + public enum NotrequiredNotnullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum NotrequiredNotnullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNotnullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNotnullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_notnullable_enum_integer_only")] + public NotrequiredNotnullableEnumIntegerOnlyEnum? NotrequiredNotnullableEnumIntegerOnly { get { return this.NotrequiredNotnullableEnumIntegerOnlyOption; } set { this.NotrequiredNotnullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines NotrequiredNotnullableEnumString + /// + public enum NotrequiredNotnullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum NotrequiredNotnullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNotnullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNotnullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNotnullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNotnullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNotnullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNotnullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNotnullableEnumStringEnumToJsonValue(NotrequiredNotnullableEnumStringEnum? value) + { + if (value == NotrequiredNotnullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNotnullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNotnullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNotnullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNotnullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNotnullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableEnumString + /// + [JsonPropertyName("notrequired_notnullable_enum_string")] + public NotrequiredNotnullableEnumStringEnum? NotrequiredNotnullableEnumString { get { return this.NotrequiredNotnullableEnumStringOption; } set { this.NotrequiredNotnullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_notnullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNotnullableOuterEnumDefaultValue { get { return this.NotrequiredNotnullableOuterEnumDefaultValueOption; } set { this.NotrequiredNotnullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumInteger + /// + public enum NotrequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum NotrequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return NotrequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerEnumToJsonValue(NotrequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumInteger + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumInteger + /// + [JsonPropertyName("notrequired_nullable_enum_integer")] + public NotrequiredNullableEnumIntegerEnum? NotrequiredNullableEnumInteger { get { return this.NotrequiredNullableEnumIntegerOption; } set { this.NotrequiredNullableEnumIntegerOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumIntegerOnly + /// + public enum NotrequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum NotrequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return NotrequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(NotrequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Used to track the state of NotrequiredNullableEnumIntegerOnly + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumIntegerOnlyOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("notrequired_nullable_enum_integer_only")] + public NotrequiredNullableEnumIntegerOnlyEnum? NotrequiredNullableEnumIntegerOnly { get { return this.NotrequiredNullableEnumIntegerOnlyOption; } set { this.NotrequiredNullableEnumIntegerOnlyOption = new Option(value); } } + + /// + /// Defines NotrequiredNullableEnumString + /// + public enum NotrequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static NotrequiredNullableEnumStringEnum NotrequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type NotrequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return NotrequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return NotrequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return NotrequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return NotrequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return NotrequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == NotrequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == NotrequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == NotrequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == NotrequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == NotrequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of NotrequiredNullableEnumString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableEnumStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableEnumString + /// + [JsonPropertyName("notrequired_nullable_enum_string")] + public NotrequiredNullableEnumStringEnum? NotrequiredNullableEnumString { get { return this.NotrequiredNullableEnumStringOption; } set { this.NotrequiredNullableEnumStringOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableOuterEnumDefaultValue + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableOuterEnumDefaultValueOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("notrequired_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? NotrequiredNullableOuterEnumDefaultValue { get { return this.NotrequiredNullableOuterEnumDefaultValueOption; } set { this.NotrequiredNullableOuterEnumDefaultValueOption = new Option(value); } } + + /// + /// Defines RequiredNullableEnumInteger + /// + public enum RequiredNullableEnumIntegerEnum + { + /// + /// Enum NUMBER_1 for value: 1 + /// + NUMBER_1 = 1, + + /// + /// Enum NUMBER_MINUS_1 for value: -1 + /// + NUMBER_MINUS_1 = -1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerEnum RequiredNullableEnumIntegerEnumFromString(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerEnum? RequiredNullableEnumIntegerEnumFromStringOrDefault(string value) + { + if (value.Equals((1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_1; + + if (value.Equals((-1).ToString())) + return RequiredNullableEnumIntegerEnum.NUMBER_MINUS_1; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerEnumToJsonValue(RequiredNullableEnumIntegerEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumInteger + /// + [JsonPropertyName("required_nullable_enum_integer")] + public RequiredNullableEnumIntegerEnum? RequiredNullableEnumInteger { get; set; } + + /// + /// Defines RequiredNullableEnumIntegerOnly + /// + public enum RequiredNullableEnumIntegerOnlyEnum + { + /// + /// Enum NUMBER_2 for value: 2 + /// + NUMBER_2 = 2, + + /// + /// Enum NUMBER_MINUS_2 for value: -2 + /// + NUMBER_MINUS_2 = -2 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum RequiredNullableEnumIntegerOnlyEnumFromString(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumIntegerOnlyEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnlyEnumFromStringOrDefault(string value) + { + if (value.Equals((2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_2; + + if (value.Equals((-2).ToString())) + return RequiredNullableEnumIntegerOnlyEnum.NUMBER_MINUS_2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + public static int RequiredNullableEnumIntegerOnlyEnumToJsonValue(RequiredNullableEnumIntegerOnlyEnum value) + { + return (int) value; + } + + /// + /// Gets or Sets RequiredNullableEnumIntegerOnly + /// + [JsonPropertyName("required_nullable_enum_integer_only")] + public RequiredNullableEnumIntegerOnlyEnum? RequiredNullableEnumIntegerOnly { get; set; } + + /// + /// Defines RequiredNullableEnumString + /// + public enum RequiredNullableEnumStringEnum + { + /// + /// Enum UPPER for value: UPPER + /// + UPPER = 1, + + /// + /// Enum Lower for value: lower + /// + Lower = 2, + + /// + /// Enum Empty for value: + /// + Empty = 3, + + /// + /// Enum ValuewithTab for value: Value\twith tab + /// + ValuewithTab = 4, + + /// + /// Enum ValueWithQuote for value: Value with \" quote + /// + ValueWithQuote = 5, + + /// + /// Enum ValueWithEscapedQuote for value: Value with escaped \" quote + /// + ValueWithEscapedQuote = 6, + + /// + /// Enum Duplicatevalue for value: Duplicate\nvalue + /// + Duplicatevalue = 7, + + /// + /// Enum Duplicatevalue2 for value: Duplicate\r\nvalue + /// + Duplicatevalue2 = 8 + } + + /// + /// Returns a + /// + /// + /// + /// + public static RequiredNullableEnumStringEnum RequiredNullableEnumStringEnumFromString(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + throw new NotImplementedException($"Could not convert value to type RequiredNullableEnumStringEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static RequiredNullableEnumStringEnum? RequiredNullableEnumStringEnumFromStringOrDefault(string value) + { + if (value.Equals("UPPER")) + return RequiredNullableEnumStringEnum.UPPER; + + if (value.Equals("lower")) + return RequiredNullableEnumStringEnum.Lower; + + if (value.Equals("")) + return RequiredNullableEnumStringEnum.Empty; + + if (value.Equals("Value\twith tab")) + return RequiredNullableEnumStringEnum.ValuewithTab; + + if (value.Equals("Value with \" quote")) + return RequiredNullableEnumStringEnum.ValueWithQuote; + + if (value.Equals("Value with escaped \" quote")) + return RequiredNullableEnumStringEnum.ValueWithEscapedQuote; + + if (value.Equals("Duplicate\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue; + + if (value.Equals("Duplicate\r\nvalue")) + return RequiredNullableEnumStringEnum.Duplicatevalue2; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value) + { + if (value == null) + return null; + + if (value == RequiredNullableEnumStringEnum.UPPER) + return "UPPER"; + + if (value == RequiredNullableEnumStringEnum.Lower) + return "lower"; + + if (value == RequiredNullableEnumStringEnum.Empty) + return ""; + + if (value == RequiredNullableEnumStringEnum.ValuewithTab) + return "Value\twith tab"; + + if (value == RequiredNullableEnumStringEnum.ValueWithQuote) + return "Value with \" quote"; + + if (value == RequiredNullableEnumStringEnum.ValueWithEscapedQuote) + return "Value with escaped \" quote"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue) + return "Duplicate\nvalue"; + + if (value == RequiredNullableEnumStringEnum.Duplicatevalue2) + return "Duplicate\r\nvalue"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Gets or Sets RequiredNullableEnumString + /// + [JsonPropertyName("required_nullable_enum_string")] + public RequiredNullableEnumStringEnum? RequiredNullableEnumString { get; set; } + + /// + /// Gets or Sets RequiredNullableOuterEnumDefaultValue + /// + [JsonPropertyName("required_nullable_outerEnumDefaultValue")] + public OuterEnumDefaultValue? RequiredNullableOuterEnumDefaultValue { get; set; } + + /// + /// Gets or Sets RequiredNotNullableDateProp + /// + [JsonPropertyName("required_not_nullable_date_prop")] + public DateTime RequiredNotNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableArrayOfString + /// + [JsonPropertyName("required_notnullable_array_of_string")] + public List RequiredNotnullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNotnullableBooleanProp + /// + [JsonPropertyName("required_notnullable_boolean_prop")] + public bool RequiredNotnullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableDatetimeProp + /// + [JsonPropertyName("required_notnullable_datetime_prop")] + public DateTime RequiredNotnullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableStringProp + /// + [JsonPropertyName("required_notnullable_string_prop")] + public string RequiredNotnullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_notnullable_uuid")] + public Guid RequiredNotnullableUuid { get; set; } + + /// + /// Gets or Sets RequiredNotnullableintegerProp + /// + [JsonPropertyName("required_notnullableinteger_prop")] + public int RequiredNotnullableintegerProp { get; set; } + + /// + /// Used to track the state of NotRequiredNotnullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableDateProp + /// + [JsonPropertyName("not_required_notnullable_date_prop")] + public DateTime? NotRequiredNotnullableDateProp { get { return this.NotRequiredNotnullableDatePropOption; } set { this.NotRequiredNotnullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNotnullableintegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNotnullableintegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNotnullableintegerProp + /// + [JsonPropertyName("not_required_notnullableinteger_prop")] + public int? NotRequiredNotnullableintegerProp { get { return this.NotRequiredNotnullableintegerPropOption; } set { this.NotRequiredNotnullableintegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableDateProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableDatePropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableDateProp + /// + [JsonPropertyName("not_required_nullable_date_prop")] + public DateTime? NotRequiredNullableDateProp { get { return this.NotRequiredNullableDatePropOption; } set { this.NotRequiredNullableDatePropOption = new Option(value); } } + + /// + /// Used to track the state of NotRequiredNullableIntegerProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotRequiredNullableIntegerPropOption { get; private set; } + + /// + /// Gets or Sets NotRequiredNullableIntegerProp + /// + [JsonPropertyName("not_required_nullable_integer_prop")] + public int? NotRequiredNullableIntegerProp { get { return this.NotRequiredNullableIntegerPropOption; } set { this.NotRequiredNullableIntegerPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNotnullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableArrayOfString + /// + [JsonPropertyName("notrequired_notnullable_array_of_string")] + public List NotrequiredNotnullableArrayOfString { get { return this.NotrequiredNotnullableArrayOfStringOption; } set { this.NotrequiredNotnullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableBooleanProp + /// + [JsonPropertyName("notrequired_notnullable_boolean_prop")] + public bool? NotrequiredNotnullableBooleanProp { get { return this.NotrequiredNotnullableBooleanPropOption; } set { this.NotrequiredNotnullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableDatetimeProp + /// + [JsonPropertyName("notrequired_notnullable_datetime_prop")] + public DateTime? NotrequiredNotnullableDatetimeProp { get { return this.NotrequiredNotnullableDatetimePropOption; } set { this.NotrequiredNotnullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableStringProp + /// + [JsonPropertyName("notrequired_notnullable_string_prop")] + public string NotrequiredNotnullableStringProp { get { return this.NotrequiredNotnullableStringPropOption; } set { this.NotrequiredNotnullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNotnullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNotnullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNotnullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_notnullable_uuid")] + public Guid? NotrequiredNotnullableUuid { get { return this.NotrequiredNotnullableUuidOption; } set { this.NotrequiredNotnullableUuidOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableArrayOfString + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> NotrequiredNullableArrayOfStringOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableArrayOfString + /// + [JsonPropertyName("notrequired_nullable_array_of_string")] + public List NotrequiredNullableArrayOfString { get { return this.NotrequiredNullableArrayOfStringOption; } set { this.NotrequiredNullableArrayOfStringOption = new Option>(value); } } + + /// + /// Used to track the state of NotrequiredNullableBooleanProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableBooleanPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableBooleanProp + /// + [JsonPropertyName("notrequired_nullable_boolean_prop")] + public bool? NotrequiredNullableBooleanProp { get { return this.NotrequiredNullableBooleanPropOption; } set { this.NotrequiredNullableBooleanPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableDatetimeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableDatetimePropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableDatetimeProp + /// + [JsonPropertyName("notrequired_nullable_datetime_prop")] + public DateTime? NotrequiredNullableDatetimeProp { get { return this.NotrequiredNullableDatetimePropOption; } set { this.NotrequiredNullableDatetimePropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableStringProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableStringPropOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableStringProp + /// + [JsonPropertyName("notrequired_nullable_string_prop")] + public string NotrequiredNullableStringProp { get { return this.NotrequiredNullableStringPropOption; } set { this.NotrequiredNullableStringPropOption = new Option(value); } } + + /// + /// Used to track the state of NotrequiredNullableUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NotrequiredNullableUuidOption { get; private set; } + + /// + /// Gets or Sets NotrequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("notrequired_nullable_uuid")] + public Guid? NotrequiredNullableUuid { get { return this.NotrequiredNullableUuidOption; } set { this.NotrequiredNullableUuidOption = new Option(value); } } + + /// + /// Gets or Sets RequiredNullableArrayOfString + /// + [JsonPropertyName("required_nullable_array_of_string")] + public List RequiredNullableArrayOfString { get; set; } + + /// + /// Gets or Sets RequiredNullableBooleanProp + /// + [JsonPropertyName("required_nullable_boolean_prop")] + public bool? RequiredNullableBooleanProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDateProp + /// + [JsonPropertyName("required_nullable_date_prop")] + public DateTime? RequiredNullableDateProp { get; set; } + + /// + /// Gets or Sets RequiredNullableDatetimeProp + /// + [JsonPropertyName("required_nullable_datetime_prop")] + public DateTime? RequiredNullableDatetimeProp { get; set; } + + /// + /// Gets or Sets RequiredNullableIntegerProp + /// + [JsonPropertyName("required_nullable_integer_prop")] + public int? RequiredNullableIntegerProp { get; set; } + + /// + /// Gets or Sets RequiredNullableStringProp + /// + [JsonPropertyName("required_nullable_string_prop")] + public string RequiredNullableStringProp { get; set; } + + /// + /// Gets or Sets RequiredNullableUuid + /// + /// 72f98069-206d-4f12-9f12-3d1e525a8e84 + [JsonPropertyName("required_nullable_uuid")] + public Guid? RequiredNullableUuid { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RequiredClass {\n"); + sb.Append(" RequiredNotNullableDateProp: ").Append(RequiredNotNullableDateProp).Append("\n"); + sb.Append(" RequiredNotnullableArrayOfString: ").Append(RequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" RequiredNotnullableBooleanProp: ").Append(RequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" RequiredNotnullableDatetimeProp: ").Append(RequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNotnullableEnumInteger: ").Append(RequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" RequiredNotnullableEnumIntegerOnly: ").Append(RequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNotnullableEnumString: ").Append(RequiredNotnullableEnumString).Append("\n"); + sb.Append(" RequiredNotnullableOuterEnumDefaultValue: ").Append(RequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNotnullableStringProp: ").Append(RequiredNotnullableStringProp).Append("\n"); + sb.Append(" RequiredNotnullableUuid: ").Append(RequiredNotnullableUuid).Append("\n"); + sb.Append(" RequiredNotnullableintegerProp: ").Append(RequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNotnullableDateProp: ").Append(NotRequiredNotnullableDateProp).Append("\n"); + sb.Append(" NotRequiredNotnullableintegerProp: ").Append(NotRequiredNotnullableintegerProp).Append("\n"); + sb.Append(" NotRequiredNullableDateProp: ").Append(NotRequiredNullableDateProp).Append("\n"); + sb.Append(" NotRequiredNullableIntegerProp: ").Append(NotRequiredNullableIntegerProp).Append("\n"); + sb.Append(" NotrequiredNotnullableArrayOfString: ").Append(NotrequiredNotnullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNotnullableBooleanProp: ").Append(NotrequiredNotnullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNotnullableDatetimeProp: ").Append(NotrequiredNotnullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumInteger: ").Append(NotrequiredNotnullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumIntegerOnly: ").Append(NotrequiredNotnullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNotnullableEnumString: ").Append(NotrequiredNotnullableEnumString).Append("\n"); + sb.Append(" NotrequiredNotnullableOuterEnumDefaultValue: ").Append(NotrequiredNotnullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNotnullableStringProp: ").Append(NotrequiredNotnullableStringProp).Append("\n"); + sb.Append(" NotrequiredNotnullableUuid: ").Append(NotrequiredNotnullableUuid).Append("\n"); + sb.Append(" NotrequiredNullableArrayOfString: ").Append(NotrequiredNullableArrayOfString).Append("\n"); + sb.Append(" NotrequiredNullableBooleanProp: ").Append(NotrequiredNullableBooleanProp).Append("\n"); + sb.Append(" NotrequiredNullableDatetimeProp: ").Append(NotrequiredNullableDatetimeProp).Append("\n"); + sb.Append(" NotrequiredNullableEnumInteger: ").Append(NotrequiredNullableEnumInteger).Append("\n"); + sb.Append(" NotrequiredNullableEnumIntegerOnly: ").Append(NotrequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" NotrequiredNullableEnumString: ").Append(NotrequiredNullableEnumString).Append("\n"); + sb.Append(" NotrequiredNullableOuterEnumDefaultValue: ").Append(NotrequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" NotrequiredNullableStringProp: ").Append(NotrequiredNullableStringProp).Append("\n"); + sb.Append(" NotrequiredNullableUuid: ").Append(NotrequiredNullableUuid).Append("\n"); + sb.Append(" RequiredNullableArrayOfString: ").Append(RequiredNullableArrayOfString).Append("\n"); + sb.Append(" RequiredNullableBooleanProp: ").Append(RequiredNullableBooleanProp).Append("\n"); + sb.Append(" RequiredNullableDateProp: ").Append(RequiredNullableDateProp).Append("\n"); + sb.Append(" RequiredNullableDatetimeProp: ").Append(RequiredNullableDatetimeProp).Append("\n"); + sb.Append(" RequiredNullableEnumInteger: ").Append(RequiredNullableEnumInteger).Append("\n"); + sb.Append(" RequiredNullableEnumIntegerOnly: ").Append(RequiredNullableEnumIntegerOnly).Append("\n"); + sb.Append(" RequiredNullableEnumString: ").Append(RequiredNullableEnumString).Append("\n"); + sb.Append(" RequiredNullableIntegerProp: ").Append(RequiredNullableIntegerProp).Append("\n"); + sb.Append(" RequiredNullableOuterEnumDefaultValue: ").Append(RequiredNullableOuterEnumDefaultValue).Append("\n"); + sb.Append(" RequiredNullableStringProp: ").Append(RequiredNullableStringProp).Append("\n"); + sb.Append(" RequiredNullableUuid: ").Append(RequiredNullableUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RequiredClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize RequiredNotNullableDateProp + /// + public static string RequiredNotNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNotnullableDatetimeProp + /// + public static string RequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotRequiredNotnullableDateProp + /// + public static string NotRequiredNotnullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotRequiredNullableDateProp + /// + public static string NotRequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize NotrequiredNotnullableDatetimeProp + /// + public static string NotrequiredNotnullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize NotrequiredNullableDatetimeProp + /// + public static string NotrequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize RequiredNullableDateProp + /// + public static string RequiredNullableDatePropFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// The format to use to serialize RequiredNullableDatetimeProp + /// + public static string RequiredNullableDatetimePropFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option requiredNotNullableDateProp = default; + Option> requiredNotnullableArrayOfString = default; + Option requiredNotnullableBooleanProp = default; + Option requiredNotnullableDatetimeProp = default; + Option requiredNotnullableEnumInteger = default; + Option requiredNotnullableEnumIntegerOnly = default; + Option requiredNotnullableEnumString = default; + Option requiredNotnullableOuterEnumDefaultValue = default; + Option requiredNotnullableStringProp = default; + Option requiredNotnullableUuid = default; + Option requiredNotnullableintegerProp = default; + Option notRequiredNotnullableDateProp = default; + Option notRequiredNotnullableintegerProp = default; + Option notRequiredNullableDateProp = default; + Option notRequiredNullableIntegerProp = default; + Option> notrequiredNotnullableArrayOfString = default; + Option notrequiredNotnullableBooleanProp = default; + Option notrequiredNotnullableDatetimeProp = default; + Option notrequiredNotnullableEnumInteger = default; + Option notrequiredNotnullableEnumIntegerOnly = default; + Option notrequiredNotnullableEnumString = default; + Option notrequiredNotnullableOuterEnumDefaultValue = default; + Option notrequiredNotnullableStringProp = default; + Option notrequiredNotnullableUuid = default; + Option> notrequiredNullableArrayOfString = default; + Option notrequiredNullableBooleanProp = default; + Option notrequiredNullableDatetimeProp = default; + Option notrequiredNullableEnumInteger = default; + Option notrequiredNullableEnumIntegerOnly = default; + Option notrequiredNullableEnumString = default; + Option notrequiredNullableOuterEnumDefaultValue = default; + Option notrequiredNullableStringProp = default; + Option notrequiredNullableUuid = default; + Option> requiredNullableArrayOfString = default; + Option requiredNullableBooleanProp = default; + Option requiredNullableDateProp = default; + Option requiredNullableDatetimeProp = default; + Option requiredNullableEnumInteger = default; + Option requiredNullableEnumIntegerOnly = default; + Option requiredNullableEnumString = default; + Option requiredNullableIntegerProp = default; + Option requiredNullableOuterEnumDefaultValue = default; + Option requiredNullableStringProp = default; + Option requiredNullableUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "required_not_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumInteger = new Option((RequiredClass.RequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableEnumIntegerOnly = new Option((RequiredClass.RequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_notnullable_enum_string": + string requiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableEnumStringRawValue != null) + requiredNotnullableEnumString = new Option(RequiredClass.RequiredNotnullableEnumStringEnumFromStringOrDefault(requiredNotnullableEnumStringRawValue)); + break; + case "required_notnullable_outerEnumDefaultValue": + string requiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNotnullableOuterEnumDefaultValueRawValue != null) + requiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "required_notnullable_string_prop": + requiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_notnullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_notnullableinteger_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNotnullableintegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "not_required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "not_required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notRequiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_notnullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_notnullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumInteger = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_notnullable_enum_string": + string notrequiredNotnullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableEnumStringRawValue != null) + notrequiredNotnullableEnumString = new Option(RequiredClass.NotrequiredNotnullableEnumStringEnumFromStringOrDefault(notrequiredNotnullableEnumStringRawValue)); + break; + case "notrequired_notnullable_outerEnumDefaultValue": + string notrequiredNotnullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNotnullableOuterEnumDefaultValueRawValue != null) + notrequiredNotnullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNotnullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_notnullable_string_prop": + notrequiredNotnullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_notnullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNotnullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "notrequired_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "notrequired_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "notrequired_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumInteger = new Option((RequiredClass.NotrequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableEnumIntegerOnly = new Option((RequiredClass.NotrequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "notrequired_nullable_enum_string": + string notrequiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableEnumStringRawValue != null) + notrequiredNullableEnumString = new Option(RequiredClass.NotrequiredNullableEnumStringEnumFromStringOrDefault(notrequiredNullableEnumStringRawValue)); + break; + case "notrequired_nullable_outerEnumDefaultValue": + string notrequiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (notrequiredNullableOuterEnumDefaultValueRawValue != null) + notrequiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(notrequiredNullableOuterEnumDefaultValueRawValue)); + break; + case "notrequired_nullable_string_prop": + notrequiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "notrequired_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + notrequiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + case "required_nullable_array_of_string": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableArrayOfString = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_boolean_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableBooleanProp = new Option(utf8JsonReader.GetBoolean()); + break; + case "required_nullable_date_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDateProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_datetime_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableDatetimeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "required_nullable_enum_integer": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumInteger = new Option((RequiredClass.RequiredNullableEnumIntegerEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_integer_only": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableEnumIntegerOnly = new Option((RequiredClass.RequiredNullableEnumIntegerOnlyEnum)utf8JsonReader.GetInt32()); + break; + case "required_nullable_enum_string": + string requiredNullableEnumStringRawValue = utf8JsonReader.GetString(); + if (requiredNullableEnumStringRawValue != null) + requiredNullableEnumString = new Option(RequiredClass.RequiredNullableEnumStringEnumFromStringOrDefault(requiredNullableEnumStringRawValue)); + break; + case "required_nullable_integer_prop": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableIntegerProp = new Option(utf8JsonReader.GetInt32()); + break; + case "required_nullable_outerEnumDefaultValue": + string requiredNullableOuterEnumDefaultValueRawValue = utf8JsonReader.GetString(); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + requiredNullableOuterEnumDefaultValue = new Option(OuterEnumDefaultValueValueConverter.FromStringOrDefault(requiredNullableOuterEnumDefaultValueRawValue)); + break; + case "required_nullable_string_prop": + requiredNullableStringProp = new Option(utf8JsonReader.GetString()); + break; + case "required_nullable_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + requiredNullableUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (!requiredNotNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotNullableDateProp)); + + if (!requiredNotnullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableArrayOfString)); + + if (!requiredNotnullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableBooleanProp)); + + if (!requiredNotnullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableDatetimeProp)); + + if (!requiredNotnullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumInteger)); + + if (!requiredNotnullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumIntegerOnly)); + + if (!requiredNotnullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableEnumString)); + + if (!requiredNotnullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableOuterEnumDefaultValue)); + + if (!requiredNotnullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableStringProp)); + + if (!requiredNotnullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableUuid)); + + if (!requiredNotnullableintegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNotnullableintegerProp)); + + if (!requiredNullableArrayOfString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableArrayOfString)); + + if (!requiredNullableBooleanProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableBooleanProp)); + + if (!requiredNullableDateProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDateProp)); + + if (!requiredNullableDatetimeProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableDatetimeProp)); + + if (!requiredNullableEnumInteger.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumInteger)); + + if (!requiredNullableEnumIntegerOnly.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumIntegerOnly)); + + if (!requiredNullableEnumString.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableEnumString)); + + if (!requiredNullableIntegerProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableIntegerProp)); + + if (!requiredNullableOuterEnumDefaultValue.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableOuterEnumDefaultValue)); + + if (!requiredNullableStringProp.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableStringProp)); + + if (!requiredNullableUuid.IsSet) + throw new ArgumentException("Property is required for class RequiredClass.", nameof(requiredNullableUuid)); + + if (requiredNotNullableDateProp.IsSet && requiredNotNullableDateProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotNullableDateProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableArrayOfString.IsSet && requiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableBooleanProp.IsSet && requiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableDatetimeProp.IsSet && requiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumInteger.IsSet && requiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumIntegerOnly.IsSet && requiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableEnumString.IsSet && requiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableOuterEnumDefaultValue.IsSet && requiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableStringProp.IsSet && requiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableUuid.IsSet && requiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass."); + + if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null) + throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass."); + + if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null) + throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass."); + + return new RequiredClass(requiredNotNullableDateProp.Value.Value, requiredNotnullableArrayOfString.Value, requiredNotnullableBooleanProp.Value.Value, requiredNotnullableDatetimeProp.Value.Value, requiredNotnullableEnumInteger.Value.Value, requiredNotnullableEnumIntegerOnly.Value.Value, requiredNotnullableEnumString.Value.Value, requiredNotnullableOuterEnumDefaultValue.Value.Value, requiredNotnullableStringProp.Value, requiredNotnullableUuid.Value.Value, requiredNotnullableintegerProp.Value.Value, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value, requiredNullableBooleanProp.Value, requiredNullableDateProp.Value, requiredNullableDatetimeProp.Value, requiredNullableEnumInteger.Value, requiredNullableEnumIntegerOnly.Value, requiredNullableEnumString.Value, requiredNullableIntegerProp.Value, requiredNullableOuterEnumDefaultValue.Value, requiredNullableStringProp.Value, requiredNullableUuid.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, requiredClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + { + if (requiredClass.RequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.RequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass."); + + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null) + throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass."); + + writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat)); + + writer.WritePropertyName("required_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNotnullableArrayOfString, jsonSerializerOptions); + writer.WriteBoolean("required_notnullable_boolean_prop", requiredClass.RequiredNotnullableBooleanProp); + + writer.WriteString("required_notnullable_datetime_prop", requiredClass.RequiredNotnullableDatetimeProp.ToString(RequiredNotnullableDatetimePropFormat)); + + writer.WriteNumber("required_notnullable_enum_integer", RequiredClass.RequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNotnullableEnumInteger)); + + writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly)); + + var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString); + writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue); + var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue); + writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue); + + writer.WriteString("required_notnullable_string_prop", requiredClass.RequiredNotnullableStringProp); + + writer.WriteString("required_notnullable_uuid", requiredClass.RequiredNotnullableUuid); + + writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp); + + if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet) + writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value.Value.ToString(NotRequiredNotnullableDatePropFormat)); + + if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet) + writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value.Value); + + if (requiredClass.NotRequiredNullableDatePropOption.IsSet) + if (requiredClass.NotRequiredNullableDatePropOption.Value != null) + writer.WriteString("not_required_nullable_date_prop", requiredClass.NotRequiredNullableDatePropOption.Value.Value.ToString(NotRequiredNullableDatePropFormat)); + else + writer.WriteNull("not_required_nullable_date_prop"); + + if (requiredClass.NotRequiredNullableIntegerPropOption.IsSet) + if (requiredClass.NotRequiredNullableIntegerPropOption.Value != null) + writer.WriteNumber("not_required_nullable_integer_prop", requiredClass.NotRequiredNullableIntegerPropOption.Value.Value); + else + writer.WriteNull("not_required_nullable_integer_prop"); + + if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet) + { + writer.WritePropertyName("notrequired_notnullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions); + } + if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet) + writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value.Value); + + if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet) + writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value.Value.ToString(NotrequiredNotnullableDatetimePropFormat)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value.Value)); + + if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet) + writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value.Value)); + + var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value.Value); + writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue); + if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet) + { + var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value); + writer.WriteString("notrequired_notnullable_outerEnumDefaultValue", notrequiredNotnullableOuterEnumDefaultValueRawValue); + } + if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet) + writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp); + + if (requiredClass.NotrequiredNotnullableUuidOption.IsSet) + writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value.Value); + + if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet) + if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null) + { + writer.WritePropertyName("notrequired_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.NotrequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("notrequired_nullable_array_of_string"); + if (requiredClass.NotrequiredNullableBooleanPropOption.IsSet) + if (requiredClass.NotrequiredNullableBooleanPropOption.Value != null) + writer.WriteBoolean("notrequired_nullable_boolean_prop", requiredClass.NotrequiredNullableBooleanPropOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_boolean_prop"); + + if (requiredClass.NotrequiredNullableDatetimePropOption.IsSet) + if (requiredClass.NotrequiredNullableDatetimePropOption.Value != null) + writer.WriteString("notrequired_nullable_datetime_prop", requiredClass.NotrequiredNullableDatetimePropOption.Value.Value.ToString(NotrequiredNullableDatetimePropFormat)); + else + writer.WriteNull("notrequired_nullable_datetime_prop"); + + if (requiredClass.NotrequiredNullableEnumIntegerOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer", RequiredClass.NotrequiredNullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer"); + + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.IsSet) + if (requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value != null) + writer.WriteNumber("notrequired_nullable_enum_integer_only", RequiredClass.NotrequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNullableEnumIntegerOnlyOption.Value.Value)); + else + writer.WriteNull("notrequired_nullable_enum_integer_only"); + + var notrequiredNullableEnumStringRawValue = RequiredClass.NotrequiredNullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNullableEnumStringOption.Value.Value); + if (notrequiredNullableEnumStringRawValue != null) + writer.WriteString("notrequired_nullable_enum_string", notrequiredNullableEnumStringRawValue); + else + writer.WriteNull("notrequired_nullable_enum_string"); + + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.IsSet) + if (requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value != null) + { + var notrequiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNullableOuterEnumDefaultValueOption.Value.Value); + writer.WriteString("notrequired_nullable_outerEnumDefaultValue", notrequiredNullableOuterEnumDefaultValueRawValue); + } + else + writer.WriteNull("notrequired_nullable_outerEnumDefaultValue"); + if (requiredClass.NotrequiredNullableStringPropOption.IsSet) + if (requiredClass.NotrequiredNullableStringPropOption.Value != null) + writer.WriteString("notrequired_nullable_string_prop", requiredClass.NotrequiredNullableStringProp); + else + writer.WriteNull("notrequired_nullable_string_prop"); + + if (requiredClass.NotrequiredNullableUuidOption.IsSet) + if (requiredClass.NotrequiredNullableUuidOption.Value != null) + writer.WriteString("notrequired_nullable_uuid", requiredClass.NotrequiredNullableUuidOption.Value.Value); + else + writer.WriteNull("notrequired_nullable_uuid"); + + if (requiredClass.RequiredNullableArrayOfString != null) + { + writer.WritePropertyName("required_nullable_array_of_string"); + JsonSerializer.Serialize(writer, requiredClass.RequiredNullableArrayOfString, jsonSerializerOptions); + } + else + writer.WriteNull("required_nullable_array_of_string"); + if (requiredClass.RequiredNullableBooleanProp != null) + writer.WriteBoolean("required_nullable_boolean_prop", requiredClass.RequiredNullableBooleanProp.Value); + else + writer.WriteNull("required_nullable_boolean_prop"); + + if (requiredClass.RequiredNullableDateProp != null) + writer.WriteString("required_nullable_date_prop", requiredClass.RequiredNullableDateProp.Value.ToString(RequiredNullableDatePropFormat)); + else + writer.WriteNull("required_nullable_date_prop"); + + if (requiredClass.RequiredNullableDatetimeProp != null) + writer.WriteString("required_nullable_datetime_prop", requiredClass.RequiredNullableDatetimeProp.Value.ToString(RequiredNullableDatetimePropFormat)); + else + writer.WriteNull("required_nullable_datetime_prop"); + + if (requiredClass.RequiredNullableEnumInteger != null) + writer.WriteNumber("required_nullable_enum_integer", RequiredClass.RequiredNullableEnumIntegerEnumToJsonValue(requiredClass.RequiredNullableEnumInteger.Value)); + else + writer.WriteNull("required_nullable_enum_integer"); + + if (requiredClass.RequiredNullableEnumIntegerOnly != null) + writer.WriteNumber("required_nullable_enum_integer_only", RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNullableEnumIntegerOnly.Value)); + else + writer.WriteNull("required_nullable_enum_integer_only"); + + var requiredNullableEnumStringRawValue = RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClass.RequiredNullableEnumString.Value); + if (requiredNullableEnumStringRawValue != null) + writer.WriteString("required_nullable_enum_string", requiredNullableEnumStringRawValue); + else + writer.WriteNull("required_nullable_enum_string"); + + if (requiredClass.RequiredNullableIntegerProp != null) + writer.WriteNumber("required_nullable_integer_prop", requiredClass.RequiredNullableIntegerProp.Value); + else + writer.WriteNull("required_nullable_integer_prop"); + + if (requiredClass.RequiredNullableOuterEnumDefaultValue == null) + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + else + { + var requiredNullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNullableOuterEnumDefaultValue.Value); + if (requiredNullableOuterEnumDefaultValueRawValue != null) + writer.WriteString("required_nullable_outerEnumDefaultValue", requiredNullableOuterEnumDefaultValueRawValue); + else + writer.WriteNull("required_nullable_outerEnumDefaultValue"); + } + + if (requiredClass.RequiredNullableStringProp != null) + writer.WriteString("required_nullable_string_prop", requiredClass.RequiredNullableStringProp); + else + writer.WriteNull("required_nullable_string_prop"); + + if (requiredClass.RequiredNullableUuid != null) + writer.WriteString("required_nullable_uuid", requiredClass.RequiredNullableUuid.Value); + else + writer.WriteNull("required_nullable_uuid"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs new file mode 100644 index 000000000000..b294720b3318 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Return.cs @@ -0,0 +1,246 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Model for testing reserved words + /// + public partial class Return : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// lock + /// abstract + /// varReturn + /// unsafe + [JsonConstructor] + public Return(string @lock, string @abstract = default, Option varReturn = default, Option @unsafe = default) + { + Lock = @lock; + Abstract = @abstract; + VarReturnOption = varReturn; + UnsafeOption = @unsafe; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Lock + /// + [JsonPropertyName("lock")] + public string Lock { get; set; } + + /// + /// Gets or Sets Abstract + /// + [JsonPropertyName("abstract")] + public string Abstract { get; set; } + + /// + /// Used to track the state of VarReturn + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarReturnOption { get; private set; } + + /// + /// Gets or Sets VarReturn + /// + [JsonPropertyName("return")] + public int? VarReturn { get { return this.VarReturnOption; } set { this.VarReturnOption = new Option(value); } } + + /// + /// Used to track the state of Unsafe + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UnsafeOption { get; private set; } + + /// + /// Gets or Sets Unsafe + /// + [JsonPropertyName("unsafe")] + public string Unsafe { get { return this.UnsafeOption; } set { this.UnsafeOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Return {\n"); + sb.Append(" Lock: ").Append(Lock).Append("\n"); + sb.Append(" Abstract: ").Append(Abstract).Append("\n"); + sb.Append(" VarReturn: ").Append(VarReturn).Append("\n"); + sb.Append(" Unsafe: ").Append(Unsafe).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ReturnJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varLock = default; + Option varAbstract = default; + Option varReturn = default; + Option varUnsafe = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "lock": + varLock = new Option(utf8JsonReader.GetString()); + break; + case "abstract": + varAbstract = new Option(utf8JsonReader.GetString()); + break; + case "return": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + varReturn = new Option(utf8JsonReader.GetInt32()); + break; + case "unsafe": + varUnsafe = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!varLock.IsSet) + throw new ArgumentException("Property is required for class Return.", nameof(varLock)); + + if (!varAbstract.IsSet) + throw new ArgumentException("Property is required for class Return.", nameof(varAbstract)); + + if (varLock.IsSet && varLock.Value == null) + throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return."); + + if (varReturn.IsSet && varReturn.Value == null) + throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return."); + + if (varUnsafe.IsSet && varUnsafe.Value == null) + throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return."); + + return new Return(varLock.Value, varAbstract.Value, varReturn, varUnsafe); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, varReturn, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + { + if (varReturn.Lock == null) + throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return."); + + if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null) + throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return."); + + writer.WriteString("lock", varReturn.Lock); + + if (varReturn.Abstract != null) + writer.WriteString("abstract", varReturn.Abstract); + else + writer.WriteNull("abstract"); + + if (varReturn.VarReturnOption.IsSet) + writer.WriteNumber("return", varReturn.VarReturnOption.Value.Value); + + if (varReturn.UnsafeOption.IsSet) + writer.WriteString("unsafe", varReturn.Unsafe); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs new file mode 100644 index 000000000000..494ee791a242 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -0,0 +1,204 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Role report Hash + /// + public partial class RolesReportsHash : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// role + /// roleUuid + [JsonConstructor] + public RolesReportsHash(Option role = default, Option roleUuid = default) + { + RoleOption = role; + RoleUuidOption = roleUuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Role + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleOption { get; private set; } + + /// + /// Gets or Sets Role + /// + [JsonPropertyName("role")] + public RolesReportsHashRole Role { get { return this.RoleOption; } set { this.RoleOption = new Option(value); } } + + /// + /// Used to track the state of RoleUuid + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option RoleUuidOption { get; private set; } + + /// + /// Gets or Sets RoleUuid + /// + [JsonPropertyName("role_uuid")] + public Guid? RoleUuid { get { return this.RoleUuidOption; } set { this.RoleUuidOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RolesReportsHash {\n"); + sb.Append(" Role: ").Append(Role).Append("\n"); + sb.Append(" RoleUuid: ").Append(RoleUuid).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RolesReportsHashJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option role = default; + Option roleUuid = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "role": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + role = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "role_uuid": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + roleUuid = new Option(utf8JsonReader.GetGuid()); + break; + default: + break; + } + } + } + + if (role.IsSet && role.Value == null) + throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash."); + + if (roleUuid.IsSet && roleUuid.Value == null) + throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash."); + + return new RolesReportsHash(role, roleUuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + { + if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null) + throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash."); + + if (rolesReportsHash.RoleOption.IsSet) + { + writer.WritePropertyName("role"); + JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions); + } + if (rolesReportsHash.RoleUuidOption.IsSet) + writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs new file mode 100644 index 000000000000..4d0df8c9fc49 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// RolesReportsHashRole + /// + public partial class RolesReportsHashRole : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// name + [JsonConstructor] + public RolesReportsHashRole(Option name = default) + { + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class RolesReportsHashRole {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class RolesReportsHashRoleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole."); + + return new RolesReportsHashRole(name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + { + if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null) + throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole."); + + if (rolesReportsHashRole.NameOption.IsSet) + writer.WriteString("name", rolesReportsHashRole.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs new file mode 100644 index 000000000000..47081ede38ef --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ScaleneTriangle + /// + public partial class ScaleneTriangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + /// triangleType + [JsonConstructor] + public ScaleneTriangle(string shapeType, string triangleType) + { + ShapeType = shapeType; + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ScaleneTriangle {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ScaleneTriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ScaleneTriangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(shapeType)); + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class ScaleneTriangle.", nameof(triangleType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ScaleneTriangle."); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class ScaleneTriangle."); + + return new ScaleneTriangle(shapeType.Value, triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + { + if (scaleneTriangle.ShapeType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.ShapeType), "Property is required for class ScaleneTriangle."); + + if (scaleneTriangle.TriangleType == null) + throw new ArgumentNullException(nameof(scaleneTriangle.TriangleType), "Property is required for class ScaleneTriangle."); + + writer.WriteString("shapeType", scaleneTriangle.ShapeType); + + writer.WriteString("triangleType", scaleneTriangle.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs new file mode 100644 index 000000000000..d4883a363a21 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Shape + /// + public partial class Shape : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Shape(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Shape(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Shape {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class Shape.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); + + if (quadrilateral != null) + return new Shape(quadrilateral); + + if (triangle != null) + return new Shape(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (shape.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); + } + + if (shape.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, shape, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs new file mode 100644 index 000000000000..3027d9142baf --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ShapeInterface + /// + public partial class ShapeInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// shapeType + [JsonConstructor] + public ShapeInterface(string shapeType) + { + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ShapeInterface {\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ShapeInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeInterface.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeInterface."); + + return new ShapeInterface(shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, shapeInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (shapeInterface.ShapeType == null) + throw new ArgumentNullException(nameof(shapeInterface.ShapeType), "Property is required for class ShapeInterface."); + + writer.WriteString("shapeType", shapeInterface.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs new file mode 100644 index 000000000000..2d9fb2cbb334 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -0,0 +1,237 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// The value may be a shape or the 'null' value. This is introduced in OAS schema >= 3.1. + /// + public partial class ShapeOrNull : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public ShapeOrNull(Triangle triangle) + { + Triangle = triangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public ShapeOrNull(Quadrilateral quadrilateral) + { + Quadrilateral = quadrilateral; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets Triangle + /// + public Triangle Triangle { get; set; } + + /// + /// Gets or Sets Quadrilateral + /// + public Quadrilateral Quadrilateral { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ShapeOrNull {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ShapeOrNullJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option shapeType = default; + + Quadrilateral quadrilateral = null; + Triangle triangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("shapeType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("Quadrilateral")) + { + Utf8JsonReader utf8JsonReaderQuadrilateral = utf8JsonReader; + quadrilateral = JsonSerializer.Deserialize(ref utf8JsonReaderQuadrilateral, jsonSerializerOptions); + } + if (discriminator.Equals("Triangle")) + { + Utf8JsonReader utf8JsonReaderTriangle = utf8JsonReader; + triangle = JsonSerializer.Deserialize(ref utf8JsonReaderTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class ShapeOrNull.", nameof(shapeType)); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); + + if (quadrilateral != null) + return new ShapeOrNull(quadrilateral); + + if (triangle != null) + return new ShapeOrNull(triangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (shapeOrNull.Triangle != null) { + TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); + } + + if (shapeOrNull.Quadrilateral != null) { + QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + } + + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs new file mode 100644 index 000000000000..3fa8bdc19177 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -0,0 +1,193 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// SimpleQuadrilateral + /// + public partial class SimpleQuadrilateral : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// quadrilateralType + /// shapeType + [JsonConstructor] + public SimpleQuadrilateral(string quadrilateralType, string shapeType) + { + QuadrilateralType = quadrilateralType; + ShapeType = shapeType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets QuadrilateralType + /// + [JsonPropertyName("quadrilateralType")] + public string QuadrilateralType { get; set; } + + /// + /// Gets or Sets ShapeType + /// + [JsonPropertyName("shapeType")] + public string ShapeType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class SimpleQuadrilateral {\n"); + sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); + sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class SimpleQuadrilateralJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override SimpleQuadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option quadrilateralType = default; + Option shapeType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "quadrilateralType": + quadrilateralType = new Option(utf8JsonReader.GetString()); + break; + case "shapeType": + shapeType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!quadrilateralType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(quadrilateralType)); + + if (!shapeType.IsSet) + throw new ArgumentException("Property is required for class SimpleQuadrilateral.", nameof(shapeType)); + + if (quadrilateralType.IsSet && quadrilateralType.Value == null) + throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class SimpleQuadrilateral."); + + if (shapeType.IsSet && shapeType.Value == null) + throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class SimpleQuadrilateral."); + + return new SimpleQuadrilateral(quadrilateralType.Value, shapeType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + { + if (simpleQuadrilateral.QuadrilateralType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.QuadrilateralType), "Property is required for class SimpleQuadrilateral."); + + if (simpleQuadrilateral.ShapeType == null) + throw new ArgumentNullException(nameof(simpleQuadrilateral.ShapeType), "Property is required for class SimpleQuadrilateral."); + + writer.WriteString("quadrilateralType", simpleQuadrilateral.QuadrilateralType); + + writer.WriteString("shapeType", simpleQuadrilateral.ShapeType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs new file mode 100644 index 000000000000..9b44556fcb0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// SpecialModelName + /// + public partial class SpecialModelName : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// varSpecialModelName + /// specialPropertyName + [JsonConstructor] + public SpecialModelName(Option varSpecialModelName = default, Option specialPropertyName = default) + { + VarSpecialModelNameOption = varSpecialModelName; + SpecialPropertyNameOption = specialPropertyName; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of VarSpecialModelName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option VarSpecialModelNameOption { get; private set; } + + /// + /// Gets or Sets VarSpecialModelName + /// + [JsonPropertyName("_special_model.name_")] + public string VarSpecialModelName { get { return this.VarSpecialModelNameOption; } set { this.VarSpecialModelNameOption = new Option(value); } } + + /// + /// Used to track the state of SpecialPropertyName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SpecialPropertyNameOption { get; private set; } + + /// + /// Gets or Sets SpecialPropertyName + /// + [JsonPropertyName("$special[property.name]")] + public long? SpecialPropertyName { get { return this.SpecialPropertyNameOption; } set { this.SpecialPropertyNameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class SpecialModelName {\n"); + sb.Append(" VarSpecialModelName: ").Append(VarSpecialModelName).Append("\n"); + sb.Append(" SpecialPropertyName: ").Append(SpecialPropertyName).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class SpecialModelNameJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option varSpecialModelName = default; + Option specialPropertyName = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "_special_model.name_": + varSpecialModelName = new Option(utf8JsonReader.GetString()); + break; + case "$special[property.name]": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + specialPropertyName = new Option(utf8JsonReader.GetInt64()); + break; + default: + break; + } + } + } + + if (varSpecialModelName.IsSet && varSpecialModelName.Value == null) + throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName."); + + if (specialPropertyName.IsSet && specialPropertyName.Value == null) + throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName."); + + return new SpecialModelName(varSpecialModelName, specialPropertyName); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, specialModelName, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + { + if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null) + throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName."); + + if (specialModelName.VarSpecialModelNameOption.IsSet) + writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName); + + if (specialModelName.SpecialPropertyNameOption.IsSet) + writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs new file mode 100644 index 000000000000..91ee6000335a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Tag.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Tag + /// + public partial class Tag : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + /// name + [JsonConstructor] + public Tag(Option id = default, Option name = default) + { + IdOption = id; + NameOption = name; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of Name + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NameOption { get; private set; } + + /// + /// Gets or Sets Name + /// + [JsonPropertyName("name")] + public string Name { get { return this.NameOption; } set { this.NameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TagJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option id = default; + Option name = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "name": + name = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag."); + + if (name.IsSet && name.Value == null) + throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag."); + + return new Tag(id, name); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, tag, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + { + if (tag.NameOption.IsSet && tag.Name == null) + throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag."); + + if (tag.IdOption.IsSet) + writer.WriteNumber("id", tag.IdOption.Value.Value); + + if (tag.NameOption.IsSet) + writer.WriteString("name", tag.Name); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs new file mode 100644 index 000000000000..1821b112bfb2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestCollectionEndingWithWordList + /// + public partial class TestCollectionEndingWithWordList : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// value + [JsonConstructor] + public TestCollectionEndingWithWordList(Option value = default) + { + ValueOption = value; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Value + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ValueOption { get; private set; } + + /// + /// Gets or Sets Value + /// + [JsonPropertyName("value")] + public string Value { get { return this.ValueOption; } set { this.ValueOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestCollectionEndingWithWordList {\n"); + sb.Append(" Value: ").Append(Value).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestCollectionEndingWithWordListJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option value = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "value": + value = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (value.IsSet && value.Value == null) + throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList."); + + return new TestCollectionEndingWithWordList(value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + { + if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList."); + + if (testCollectionEndingWithWordList.ValueOption.IsSet) + writer.WriteString("value", testCollectionEndingWithWordList.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs new file mode 100644 index 000000000000..433bfa41bae1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -0,0 +1,178 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestCollectionEndingWithWordListObject + /// + public partial class TestCollectionEndingWithWordListObject : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// testCollectionEndingWithWordList + [JsonConstructor] + public TestCollectionEndingWithWordListObject(Option> testCollectionEndingWithWordList = default) + { + TestCollectionEndingWithWordListOption = testCollectionEndingWithWordList; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of TestCollectionEndingWithWordList + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option> TestCollectionEndingWithWordListOption { get; private set; } + + /// + /// Gets or Sets TestCollectionEndingWithWordList + /// + [JsonPropertyName("TestCollectionEndingWithWordList")] + public List TestCollectionEndingWithWordList { get { return this.TestCollectionEndingWithWordListOption; } set { this.TestCollectionEndingWithWordListOption = new Option>(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestCollectionEndingWithWordListObject {\n"); + sb.Append(" TestCollectionEndingWithWordList: ").Append(TestCollectionEndingWithWordList).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestCollectionEndingWithWordListObjectJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option> testCollectionEndingWithWordList = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "TestCollectionEndingWithWordList": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + testCollectionEndingWithWordList = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject."); + + return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + { + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null) + throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject."); + + if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet) + { + writer.WritePropertyName("TestCollectionEndingWithWordList"); + JsonSerializer.Serialize(writer, testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs new file mode 100644 index 000000000000..1cb26beb9347 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestInlineFreeformAdditionalPropertiesRequest + /// + public partial class TestInlineFreeformAdditionalPropertiesRequest : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// someProperty + [JsonConstructor] + public TestInlineFreeformAdditionalPropertiesRequest(Option someProperty = default) + { + SomePropertyOption = someProperty; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of SomeProperty + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option SomePropertyOption { get; private set; } + + /// + /// Gets or Sets SomeProperty + /// + [JsonPropertyName("someProperty")] + public string SomeProperty { get { return this.SomePropertyOption; } set { this.SomePropertyOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TestInlineFreeformAdditionalPropertiesRequest {\n"); + sb.Append(" SomeProperty: ").Append(SomeProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestInlineFreeformAdditionalPropertiesRequestJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option someProperty = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "someProperty": + someProperty = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (someProperty.IsSet && someProperty.Value == null) + throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest."); + + return new TestInlineFreeformAdditionalPropertiesRequest(someProperty); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + { + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null) + throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest."); + + if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet) + writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs new file mode 100644 index 000000000000..d31d2948c652 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -0,0 +1,266 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Triangle + /// + public partial class Triangle : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(EquilateralTriangle equilateralTriangle) + { + EquilateralTriangle = equilateralTriangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(IsoscelesTriangle isoscelesTriangle) + { + IsoscelesTriangle = isoscelesTriangle; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Triangle(ScaleneTriangle scaleneTriangle) + { + ScaleneTriangle = scaleneTriangle; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets EquilateralTriangle + /// + public EquilateralTriangle EquilateralTriangle { get; set; } + + /// + /// Gets or Sets IsoscelesTriangle + /// + public IsoscelesTriangle IsoscelesTriangle { get; set; } + + /// + /// Gets or Sets ScaleneTriangle + /// + public ScaleneTriangle ScaleneTriangle { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Triangle {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TriangleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option triangleType = default; + + EquilateralTriangle equilateralTriangle = null; + IsoscelesTriangle isoscelesTriangle = null; + ScaleneTriangle scaleneTriangle = null; + + Utf8JsonReader utf8JsonReaderDiscriminator = utf8JsonReader; + while (utf8JsonReaderDiscriminator.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderDiscriminator.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth) + break; + + if (utf8JsonReaderDiscriminator.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderDiscriminator.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReaderDiscriminator.GetString(); + utf8JsonReaderDiscriminator.Read(); + if (localVarJsonPropertyName.Equals("triangleType")) + { + string discriminator = utf8JsonReaderDiscriminator.GetString(); + if (discriminator.Equals("EquilateralTriangle")) + { + Utf8JsonReader utf8JsonReaderEquilateralTriangle = utf8JsonReader; + equilateralTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderEquilateralTriangle, jsonSerializerOptions); + } + if (discriminator.Equals("IsoscelesTriangle")) + { + Utf8JsonReader utf8JsonReaderIsoscelesTriangle = utf8JsonReader; + isoscelesTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderIsoscelesTriangle, jsonSerializerOptions); + } + if (discriminator.Equals("ScaleneTriangle")) + { + Utf8JsonReader utf8JsonReaderScaleneTriangle = utf8JsonReader; + scaleneTriangle = JsonSerializer.Deserialize(ref utf8JsonReaderScaleneTriangle, jsonSerializerOptions); + } + } + } + } + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class Triangle.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); + + if (equilateralTriangle != null) + return new Triangle(equilateralTriangle); + + if (isoscelesTriangle != null) + return new Triangle(isoscelesTriangle); + + if (scaleneTriangle != null) + return new Triangle(scaleneTriangle); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (triangle.EquilateralTriangle != null) { + EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); + } + + if (triangle.IsoscelesTriangle != null) { + IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + } + + if (triangle.ScaleneTriangle != null) { + ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); + } + + WriteProperties(writer, triangle, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs new file mode 100644 index 000000000000..aa6d31b91909 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -0,0 +1,169 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// TriangleInterface + /// + public partial class TriangleInterface : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// triangleType + [JsonConstructor] + public TriangleInterface(string triangleType) + { + TriangleType = triangleType; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets TriangleType + /// + [JsonPropertyName("triangleType")] + public string TriangleType { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class TriangleInterface {\n"); + sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TriangleInterfaceJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TriangleInterface Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option triangleType = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "triangleType": + triangleType = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!triangleType.IsSet) + throw new ArgumentException("Property is required for class TriangleInterface.", nameof(triangleType)); + + if (triangleType.IsSet && triangleType.Value == null) + throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class TriangleInterface."); + + return new TriangleInterface(triangleType.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, triangleInterface, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + { + if (triangleInterface.TriangleType == null) + throw new ArgumentNullException(nameof(triangleInterface.TriangleType), "Property is required for class TriangleInterface."); + + writer.WriteString("triangleType", triangleInterface.TriangleType); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs new file mode 100644 index 000000000000..a2f3e4a18a69 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/User.cs @@ -0,0 +1,497 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// User + /// + public partial class User : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + /// email + /// firstName + /// id + /// lastName + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// password + /// phone + /// User Status + /// username + [JsonConstructor] + public User(Option anyTypeProp = default, Option anyTypePropNullable = default, Option email = default, Option firstName = default, Option id = default, Option lastName = default, Option objectWithNoDeclaredProps = default, Option objectWithNoDeclaredPropsNullable = default, Option password = default, Option phone = default, Option userStatus = default, Option username = default) + { + AnyTypePropOption = anyTypeProp; + AnyTypePropNullableOption = anyTypePropNullable; + EmailOption = email; + FirstNameOption = firstName; + IdOption = id; + LastNameOption = lastName; + ObjectWithNoDeclaredPropsOption = objectWithNoDeclaredProps; + ObjectWithNoDeclaredPropsNullableOption = objectWithNoDeclaredPropsNullable; + PasswordOption = password; + PhoneOption = phone; + UserStatusOption = userStatus; + UsernameOption = username; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of AnyTypeProp + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropOption { get; private set; } + + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389 + [JsonPropertyName("anyTypeProp")] + public Object AnyTypeProp { get { return this.AnyTypePropOption; } set { this.AnyTypePropOption = new Option(value); } } + + /// + /// Used to track the state of AnyTypePropNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option AnyTypePropNullableOption { get; private set; } + + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + /// + /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values. + [JsonPropertyName("anyTypePropNullable")] + public Object AnyTypePropNullable { get { return this.AnyTypePropNullableOption; } set { this.AnyTypePropNullableOption = new Option(value); } } + + /// + /// Used to track the state of Email + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option EmailOption { get; private set; } + + /// + /// Gets or Sets Email + /// + [JsonPropertyName("email")] + public string Email { get { return this.EmailOption; } set { this.EmailOption = new Option(value); } } + + /// + /// Used to track the state of FirstName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option FirstNameOption { get; private set; } + + /// + /// Gets or Sets FirstName + /// + [JsonPropertyName("firstName")] + public string FirstName { get { return this.FirstNameOption; } set { this.FirstNameOption = new Option(value); } } + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public long? Id { get { return this.IdOption; } set { this.IdOption = new Option(value); } } + + /// + /// Used to track the state of LastName + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option LastNameOption { get; private set; } + + /// + /// Gets or Sets LastName + /// + [JsonPropertyName("lastName")] + public string LastName { get { return this.LastNameOption; } set { this.LastNameOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredProps + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsOption { get; private set; } + + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + /// + /// test code generation for objects Value must be a map of strings to values. It cannot be the 'null' value. + [JsonPropertyName("objectWithNoDeclaredProps")] + public Object ObjectWithNoDeclaredProps { get { return this.ObjectWithNoDeclaredPropsOption; } set { this.ObjectWithNoDeclaredPropsOption = new Option(value); } } + + /// + /// Used to track the state of ObjectWithNoDeclaredPropsNullable + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ObjectWithNoDeclaredPropsNullableOption { get; private set; } + + /// + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + /// + /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value. + [JsonPropertyName("objectWithNoDeclaredPropsNullable")] + public Object ObjectWithNoDeclaredPropsNullable { get { return this.ObjectWithNoDeclaredPropsNullableOption; } set { this.ObjectWithNoDeclaredPropsNullableOption = new Option(value); } } + + /// + /// Used to track the state of Password + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PasswordOption { get; private set; } + + /// + /// Gets or Sets Password + /// + [JsonPropertyName("password")] + public string Password { get { return this.PasswordOption; } set { this.PasswordOption = new Option(value); } } + + /// + /// Used to track the state of Phone + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option PhoneOption { get; private set; } + + /// + /// Gets or Sets Phone + /// + [JsonPropertyName("phone")] + public string Phone { get { return this.PhoneOption; } set { this.PhoneOption = new Option(value); } } + + /// + /// Used to track the state of UserStatus + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UserStatusOption { get; private set; } + + /// + /// User Status + /// + /// User Status + [JsonPropertyName("userStatus")] + public int? UserStatus { get { return this.UserStatusOption; } set { this.UserStatusOption = new Option(value); } } + + /// + /// Used to track the state of Username + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option UsernameOption { get; private set; } + + /// + /// Gets or Sets Username + /// + [JsonPropertyName("username")] + public string Username { get { return this.UsernameOption; } set { this.UsernameOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class User {\n"); + sb.Append(" AnyTypeProp: ").Append(AnyTypeProp).Append("\n"); + sb.Append(" AnyTypePropNullable: ").Append(AnyTypePropNullable).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" ObjectWithNoDeclaredProps: ").Append(ObjectWithNoDeclaredProps).Append("\n"); + sb.Append(" ObjectWithNoDeclaredPropsNullable: ").Append(ObjectWithNoDeclaredPropsNullable).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(" Username: ").Append(Username).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class UserJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option anyTypeProp = default; + Option anyTypePropNullable = default; + Option email = default; + Option firstName = default; + Option id = default; + Option lastName = default; + Option objectWithNoDeclaredProps = default; + Option objectWithNoDeclaredPropsNullable = default; + Option password = default; + Option phone = default; + Option userStatus = default; + Option username = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "anyTypeProp": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anyTypeProp = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "anyTypePropNullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + anyTypePropNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "email": + email = new Option(utf8JsonReader.GetString()); + break; + case "firstName": + firstName = new Option(utf8JsonReader.GetString()); + break; + case "id": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + id = new Option(utf8JsonReader.GetInt64()); + break; + case "lastName": + lastName = new Option(utf8JsonReader.GetString()); + break; + case "objectWithNoDeclaredProps": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredProps = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "objectWithNoDeclaredPropsNullable": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + objectWithNoDeclaredPropsNullable = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "password": + password = new Option(utf8JsonReader.GetString()); + break; + case "phone": + phone = new Option(utf8JsonReader.GetString()); + break; + case "userStatus": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + userStatus = new Option(utf8JsonReader.GetInt32()); + break; + case "username": + username = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (email.IsSet && email.Value == null) + throw new ArgumentNullException(nameof(email), "Property is not nullable for class User."); + + if (firstName.IsSet && firstName.Value == null) + throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User."); + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class User."); + + if (lastName.IsSet && lastName.Value == null) + throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User."); + + if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null) + throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User."); + + if (password.IsSet && password.Value == null) + throw new ArgumentNullException(nameof(password), "Property is not nullable for class User."); + + if (phone.IsSet && phone.Value == null) + throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User."); + + if (userStatus.IsSet && userStatus.Value == null) + throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User."); + + if (username.IsSet && username.Value == null) + throw new ArgumentNullException(nameof(username), "Property is not nullable for class User."); + + return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, user, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + { + if (user.EmailOption.IsSet && user.Email == null) + throw new ArgumentNullException(nameof(user.Email), "Property is required for class User."); + + if (user.FirstNameOption.IsSet && user.FirstName == null) + throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User."); + + if (user.LastNameOption.IsSet && user.LastName == null) + throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User."); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null) + throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User."); + + if (user.PasswordOption.IsSet && user.Password == null) + throw new ArgumentNullException(nameof(user.Password), "Property is required for class User."); + + if (user.PhoneOption.IsSet && user.Phone == null) + throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User."); + + if (user.UsernameOption.IsSet && user.Username == null) + throw new ArgumentNullException(nameof(user.Username), "Property is required for class User."); + + if (user.AnyTypePropOption.IsSet) + if (user.AnyTypePropOption.Value != null) + { + writer.WritePropertyName("anyTypeProp"); + JsonSerializer.Serialize(writer, user.AnyTypeProp, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypeProp"); + if (user.AnyTypePropNullableOption.IsSet) + if (user.AnyTypePropNullableOption.Value != null) + { + writer.WritePropertyName("anyTypePropNullable"); + JsonSerializer.Serialize(writer, user.AnyTypePropNullable, jsonSerializerOptions); + } + else + writer.WriteNull("anyTypePropNullable"); + if (user.EmailOption.IsSet) + writer.WriteString("email", user.Email); + + if (user.FirstNameOption.IsSet) + writer.WriteString("firstName", user.FirstName); + + if (user.IdOption.IsSet) + writer.WriteNumber("id", user.IdOption.Value.Value); + + if (user.LastNameOption.IsSet) + writer.WriteString("lastName", user.LastName); + + if (user.ObjectWithNoDeclaredPropsOption.IsSet) + { + writer.WritePropertyName("objectWithNoDeclaredProps"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredProps, jsonSerializerOptions); + } + if (user.ObjectWithNoDeclaredPropsNullableOption.IsSet) + if (user.ObjectWithNoDeclaredPropsNullableOption.Value != null) + { + writer.WritePropertyName("objectWithNoDeclaredPropsNullable"); + JsonSerializer.Serialize(writer, user.ObjectWithNoDeclaredPropsNullable, jsonSerializerOptions); + } + else + writer.WriteNull("objectWithNoDeclaredPropsNullable"); + if (user.PasswordOption.IsSet) + writer.WriteString("password", user.Password); + + if (user.PhoneOption.IsSet) + writer.WriteString("phone", user.Phone); + + if (user.UserStatusOption.IsSet) + writer.WriteNumber("userStatus", user.UserStatusOption.Value.Value); + + if (user.UsernameOption.IsSet) + writer.WriteString("username", user.Username); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs new file mode 100644 index 000000000000..b93046c5457b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Whale.cs @@ -0,0 +1,223 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Whale + /// + public partial class Whale : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + /// hasBaleen + /// hasTeeth + [JsonConstructor] + public Whale(string className, Option hasBaleen = default, Option hasTeeth = default) + { + ClassName = className; + HasBaleenOption = hasBaleen; + HasTeethOption = hasTeeth; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Used to track the state of HasBaleen + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasBaleenOption { get; private set; } + + /// + /// Gets or Sets HasBaleen + /// + [JsonPropertyName("hasBaleen")] + public bool? HasBaleen { get { return this.HasBaleenOption; } set { this.HasBaleenOption = new Option(value); } } + + /// + /// Used to track the state of HasTeeth + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option HasTeethOption { get; private set; } + + /// + /// Gets or Sets HasTeeth + /// + [JsonPropertyName("hasTeeth")] + public bool? HasTeeth { get { return this.HasTeethOption; } set { this.HasTeethOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Whale {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" HasBaleen: ").Append(HasBaleen).Append("\n"); + sb.Append(" HasTeeth: ").Append(HasTeeth).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class WhaleJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option hasBaleen = default; + Option hasTeeth = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "hasBaleen": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + hasBaleen = new Option(utf8JsonReader.GetBoolean()); + break; + case "hasTeeth": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + hasTeeth = new Option(utf8JsonReader.GetBoolean()); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Whale.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale."); + + if (hasBaleen.IsSet && hasBaleen.Value == null) + throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale."); + + if (hasTeeth.IsSet && hasTeeth.Value == null) + throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale."); + + return new Whale(className.Value, hasBaleen, hasTeeth); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, whale, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + { + if (whale.ClassName == null) + throw new ArgumentNullException(nameof(whale.ClassName), "Property is required for class Whale."); + + writer.WriteString("className", whale.ClassName); + + if (whale.HasBaleenOption.IsSet) + writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value.Value); + + if (whale.HasTeethOption.IsSet) + writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value.Value); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs new file mode 100644 index 000000000000..c09d71736d1b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Zebra.cs @@ -0,0 +1,277 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Zebra + /// + public partial class Zebra : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// className + /// type + [JsonConstructor] + public Zebra(string className, Option type = default) + { + ClassName = className; + TypeOption = type; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Type + /// + public enum TypeEnum + { + /// + /// Enum Plains for value: plains + /// + Plains = 1, + + /// + /// Enum Mountain for value: mountain + /// + Mountain = 2, + + /// + /// Enum Grevys for value: grevys + /// + Grevys = 3 + } + + /// + /// Returns a + /// + /// + /// + /// + public static TypeEnum TypeEnumFromString(string value) + { + if (value.Equals("plains")) + return TypeEnum.Plains; + + if (value.Equals("mountain")) + return TypeEnum.Mountain; + + if (value.Equals("grevys")) + return TypeEnum.Grevys; + + throw new NotImplementedException($"Could not convert value to type TypeEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static TypeEnum? TypeEnumFromStringOrDefault(string value) + { + if (value.Equals("plains")) + return TypeEnum.Plains; + + if (value.Equals("mountain")) + return TypeEnum.Mountain; + + if (value.Equals("grevys")) + return TypeEnum.Grevys; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string TypeEnumToJsonValue(TypeEnum? value) + { + if (value == TypeEnum.Plains) + return "plains"; + + if (value == TypeEnum.Mountain) + return "mountain"; + + if (value == TypeEnum.Grevys) + return "grevys"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of Type + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TypeOption { get; private set; } + + /// + /// Gets or Sets Type + /// + [JsonPropertyName("type")] + public TypeEnum? Type { get { return this.TypeOption; } set { this.TypeOption = new Option(value); } } + + /// + /// Gets or Sets ClassName + /// + [JsonPropertyName("className")] + public string ClassName { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class Zebra {\n"); + sb.Append(" ClassName: ").Append(ClassName).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ZebraJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option className = default; + Option type = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "className": + className = new Option(utf8JsonReader.GetString()); + break; + case "type": + string typeRawValue = utf8JsonReader.GetString(); + if (typeRawValue != null) + type = new Option(Zebra.TypeEnumFromStringOrDefault(typeRawValue)); + break; + default: + break; + } + } + } + + if (!className.IsSet) + throw new ArgumentException("Property is required for class Zebra.", nameof(className)); + + if (className.IsSet && className.Value == null) + throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra."); + + if (type.IsSet && type.Value == null) + throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra."); + + return new Zebra(className.Value, type); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, zebra, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + { + if (zebra.ClassName == null) + throw new ArgumentNullException(nameof(zebra.ClassName), "Property is required for class Zebra."); + + writer.WriteString("className", zebra.ClassName); + + var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value.Value); + writer.WriteString("type", typeRawValue); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs new file mode 100644 index 000000000000..34a044fb8b13 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnum.cs @@ -0,0 +1,174 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines ZeroBasedEnum + /// + public enum ZeroBasedEnum + { + /// + /// Enum Unknown for value: unknown + /// + Unknown, + + /// + /// Enum NotUnknown for value: notUnknown + /// + NotUnknown + } + + /// + /// Converts to and from the JSON value + /// + public static class ZeroBasedEnumValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnum FromString(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnum.NotUnknown; + + throw new NotImplementedException($"Could not convert value to type ZeroBasedEnum: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static ZeroBasedEnum? FromStringOrDefault(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnum.NotUnknown; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(ZeroBasedEnum value) + { + if (value == ZeroBasedEnum.Unknown) + return "unknown"; + + if (value == ZeroBasedEnum.NotUnknown) + return "notUnknown"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class ZeroBasedEnumJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the ZeroBasedEnum to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnum zeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnum.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class ZeroBasedEnumNullableJsonConverter : JsonConverter + { + /// + /// Returns a ZeroBasedEnum from the Json object + /// + /// + /// + /// + /// + public override ZeroBasedEnum? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + ZeroBasedEnum? result = rawValue == null + ? null + : ZeroBasedEnumValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnum? zeroBasedEnum, JsonSerializerOptions options) + { + writer.WriteStringValue(zeroBasedEnum?.ToString() ?? "null"); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs new file mode 100644 index 000000000000..6e6bf0004c21 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -0,0 +1,239 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// ZeroBasedEnumClass + /// + public partial class ZeroBasedEnumClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// zeroBasedEnum + [JsonConstructor] + public ZeroBasedEnumClass(Option zeroBasedEnum = default) + { + ZeroBasedEnumOption = zeroBasedEnum; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines ZeroBasedEnum + /// + public enum ZeroBasedEnumEnum + { + /// + /// Enum Unknown for value: unknown + /// + Unknown, + + /// + /// Enum NotUnknown for value: notUnknown + /// + NotUnknown + } + + /// + /// Returns a + /// + /// + /// + /// + public static ZeroBasedEnumEnum ZeroBasedEnumEnumFromString(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnumEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnumEnum.NotUnknown; + + throw new NotImplementedException($"Could not convert value to type ZeroBasedEnumEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static ZeroBasedEnumEnum? ZeroBasedEnumEnumFromStringOrDefault(string value) + { + if (value.Equals("unknown")) + return ZeroBasedEnumEnum.Unknown; + + if (value.Equals("notUnknown")) + return ZeroBasedEnumEnum.NotUnknown; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ZeroBasedEnumEnumToJsonValue(ZeroBasedEnumEnum? value) + { + if (value == ZeroBasedEnumEnum.Unknown) + return "unknown"; + + if (value == ZeroBasedEnumEnum.NotUnknown) + return "notUnknown"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// Used to track the state of ZeroBasedEnum + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ZeroBasedEnumOption { get; private set; } + + /// + /// Gets or Sets ZeroBasedEnum + /// + [JsonPropertyName("ZeroBasedEnum")] + public ZeroBasedEnumEnum? ZeroBasedEnum { get { return this.ZeroBasedEnumOption; } set { this.ZeroBasedEnumOption = new Option(value); } } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class ZeroBasedEnumClass {\n"); + sb.Append(" ZeroBasedEnum: ").Append(ZeroBasedEnum).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ZeroBasedEnumClassJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option zeroBasedEnum = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "ZeroBasedEnum": + string zeroBasedEnumRawValue = utf8JsonReader.GetString(); + if (zeroBasedEnumRawValue != null) + zeroBasedEnum = new Option(ZeroBasedEnumClass.ZeroBasedEnumEnumFromStringOrDefault(zeroBasedEnumRawValue)); + break; + default: + break; + } + } + } + + if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null) + throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass."); + + return new ZeroBasedEnumClass(zeroBasedEnum); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + { + var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value); + writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..c6529e054024 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,33 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..bd9faa467e44 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/README.md @@ -0,0 +1,223 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=false', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + Call123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo"); + ModelClient model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + // the type of token here depends on the api security specifications + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); + options.AddTokens(token); + + // optionally choose the method the tokens will be provided with, default is RateLimitProvider + options.UseProvider, ApiKeyToken>(); + + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: +- write:pets: modify pets in your account +- read:pets: read your pets + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + + +### http_basic_test + +- **Type**: HTTP basic authentication + + +### bearer_test + +- **Type**: Bearer Authentication + + +### http_signature_test + +- **Type**: HTTP signature authentication + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: OpenAPI Petstore +- appVersion: 1.0.0 +- appDescription: This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: false +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: false +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {321C8C3F-0156-40C1-AE42-D59761FB9B6C} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project. diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.gitignore b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.gitignore new file mode 100644 index 000000000000..1ee53850b84c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.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/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator-ignore b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.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/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES new file mode 100644 index 000000000000..5abbcf46f35c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/FILES @@ -0,0 +1,36 @@ +.gitignore +Org.OpenAPITools.sln +README.md +api/openapi.yaml +appveyor.yml +docs/apis/DefaultApi.md +docs/models/NowGet200Response.md +docs/scripts/git_push.ps1 +docs/scripts/git_push.sh +src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj +src/Org.OpenAPITools.Test/README.md +src/Org.OpenAPITools/Api/DefaultApi.cs +src/Org.OpenAPITools/Api/IApi.cs +src/Org.OpenAPITools/Client/ApiException.cs +src/Org.OpenAPITools/Client/ApiFactory.cs +src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs +src/Org.OpenAPITools/Client/ApiResponse`1.cs +src/Org.OpenAPITools/Client/ClientUtils.cs +src/Org.OpenAPITools/Client/CookieContainer.cs +src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs +src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs +src/Org.OpenAPITools/Client/ExceptionEventArgs.cs +src/Org.OpenAPITools/Client/HostConfiguration.cs +src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs +src/Org.OpenAPITools/Client/Option.cs +src/Org.OpenAPITools/Client/RateLimitProvider`1.cs +src/Org.OpenAPITools/Client/TokenBase.cs +src/Org.OpenAPITools/Client/TokenContainer`1.cs +src/Org.OpenAPITools/Client/TokenProvider`1.cs +src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs +src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs +src/Org.OpenAPITools/Model/NowGet200Response.cs +src/Org.OpenAPITools/Org.OpenAPITools.csproj +src/Org.OpenAPITools/README.md diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/VERSION b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/VERSION new file mode 100644 index 000000000000..7e7b8b9bc733 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.7.0-SNAPSHOT diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/Org.OpenAPITools.sln b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/Org.OpenAPITools.sln new file mode 100644 index 000000000000..547505a9856b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools.Test", "src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E60EF87-DB0B-4D01-A36E-F5E90F7EC757}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/README.md b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/README.md new file mode 100644 index 000000000000..f9c1c7f74621 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/README.md @@ -0,0 +1 @@ +# Created with Openapi Generator diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/api/openapi.yaml new file mode 100644 index 000000000000..a84e041a00fa --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/api/openapi.yaml @@ -0,0 +1,35 @@ +openapi: 3.0.0 +info: + description: Thic spec contains endpoints with dates in different formats + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Dates + version: 1.0.0 +servers: +- url: / +paths: + /now: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/_now_get_200_response' + description: now dates +components: + schemas: + _now_get_200_response: + example: + today: 2000-01-23 + now: 2000-01-23T04:56:07.000+00:00 + properties: + today: + format: date + type: string + now: + format: date-time + type: string + type: object + diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/appveyor.yml b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/appveyor.yml new file mode 100644 index 000000000000..f76f63cee506 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/appveyor.yml @@ -0,0 +1,9 @@ +# auto-generated by OpenAPI Generator (https://github.com/OpenAPITools/openapi-generator) +# +image: Visual Studio 2019 +clone_depth: 1 +build_script: +- dotnet build -c Release +- dotnet test -c Release +after_build: +- dotnet pack .\src\Org.OpenAPITools\Org.OpenAPITools.csproj -o ../../output -c Release --no-build diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/apis/DefaultApi.md b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/apis/DefaultApi.md new file mode 100644 index 000000000000..6b1991021ac2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/apis/DefaultApi.md @@ -0,0 +1,90 @@ +# Org.OpenAPITools.Api.DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|--------|--------------|-------------| +| [**NowGet**](DefaultApi.md#nowget) | **GET** /now | | + + +# **NowGet** +> NowGet200Response NowGet () + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class NowGetExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://localhost"; + var apiInstance = new DefaultApi(config); + + try + { + NowGet200Response result = apiInstance.NowGet(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.NowGet: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the NowGetWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + ApiResponse response = apiInstance.NowGetWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.NowGetWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**NowGet200Response**](NowGet200Response.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | now dates | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/models/NowGet200Response.md b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/models/NowGet200Response.md new file mode 100644 index 000000000000..58b6c7c79f01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/models/NowGet200Response.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.NowGet200Response + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Now** | **DateTime** | | [optional] +**Today** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.ps1 b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.ps1 new file mode 100644 index 000000000000..73ed35c2bb10 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.ps1 @@ -0,0 +1,75 @@ +param( + [Parameter()][Alias("g")][String]$GitHost = "github.com", + [Parameter()][Alias("u")][String]$GitUserId = "GIT_USER_ID", + [Parameter()][Alias("r")][String]$GitRepoId = "GIT_REPO_ID", + [Parameter()][Alias("m")][string]$Message = "Minor update", + [Parameter()][Alias("h")][switch]$Help +) + +function Publish-ToGitHost{ + if ([string]::IsNullOrWhiteSpace($Message) -or $Message -eq "Minor update"){ + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + $Message = Read-Host -Prompt "Please provide a commit message or press enter" + $Message = if([string]::IsNullOrWhiteSpace($Message)) { "no message provided" } else { $Message } + } + + git init + git add . + git commit -am "${Message}" + $branchName=$(git rev-parse --abbrev-ref HEAD) + $gitRemote=$(git remote) + + if([string]::IsNullOrWhiteSpace($gitRemote)){ + git remote add origin https://${GitHost}/${GitUserId}/${GitRepoId}.git + } + + Write-Output "Pulling from https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git pull origin $branchName --ff-only + + if ($LastExitCode -ne 0){ + if (${GitHost} -eq "github.com"){ + Write-Output "The ${GitRepoId} repository may not exist yet. Creating it now with the GitHub CLI." + gh auth login --hostname github.com --web + gh repo create $GitRepoId --private + # sleep 2 seconds to ensure git finishes creation of the repo + Start-Sleep -Seconds 2 + } + else{ + throw "There was an issue pulling the origin branch. The remote repository may not exist yet." + } + } + + Write-Output "Pushing to https://${GitHost}/${GitUserId}/${GitRepoId}.git" + git push origin $branchName +} + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 3.0 + +if ($Help){ + Write-Output " + This script will initialize a git repository, then add and commit all files. + The local repository will then be pushed to your preferred git provider. + If the remote repository does not exist yet and you are using GitHub, + the repository will be created for you provided you have the GitHub CLI installed. + + Parameters: + -g | -GitHost -> ex: github.com + -m | -Message -> the git commit message + -r | -GitRepoId -> the name of the repository + -u | -GitUserId -> your user id + " + + return +} + +$rootPath=Resolve-Path -Path $PSScriptRoot/../.. + +Push-Location $rootPath + +try { + Publish-ToGitHost $GitHost $GitUserId $GitRepoId $Message +} +finally{ + Pop-Location +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.sh b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.sh new file mode 100644 index 000000000000..882104922184 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/docs/scripts/git_push.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=${1:-GIT_USER_ID} +git_repo_id=${2:-GIT_REPO_ID} +release_note=${3:-Minor update} +git_host=${4:-github.com} + +starting_directory=$(pwd) +script_root="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd $script_root +cd ../.. + +if [ "$release_note" = "" ] || [ "$release_note" = "Minor update" ]; then + # it seems unlikely that we would want our git commit message to be the default, so lets prompt the user + echo "Please provide a commit message or press enter" + read user_input + release_note=$user_input + if [ "$release_note" = "" ]; then + release_note="no message provided" + fi +fi + +git init +git add . +git commit -am "$release_note" +branch_name=$(git rev-parse --abbrev-ref HEAD) +git_remote=$(git remote) + +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +echo "[INFO] Pulling from https://${git_host}/${git_user_id}/${git_repo_id}.git" +git pull origin $branch_name --ff-only + +echo "[INFO] Pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin $branch_name + +cd $starting_directory diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs new file mode 100644 index 000000000000..40e1298ee62c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/ApiTestsBase.cs @@ -0,0 +1,58 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Extensions; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Base class for API tests + /// + public class ApiTestsBase + { + protected readonly IHost _host; + + public ApiTestsBase(string[] args) + { + _host = CreateHostBuilder(args).Build(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, services, options) => + { + + }); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs new file mode 100644 index 000000000000..05dc933c03b1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DefaultApiTests.cs @@ -0,0 +1,64 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + + +/* ********************************************************************************* +* Follow these manual steps to construct tests. +* This file will not be overwritten. +* ********************************************************************************* +* 1. Navigate to ApiTests.Base.cs and ensure any tokens are being created correctly. +* Take care not to commit credentials to any repository. +* +* 2. Mocking is coordinated by ApiTestsBase#AddApiHttpClients. +* To mock the client, use the generic AddApiHttpClients. +* To mock the server, change the client's BaseAddress. +* +* 3. Locate the test you want below +* - remove the skip property from the Fact attribute +* - set the value of any variables if necessary +* +* 4. Run the tests and ensure they work. +* +*/ + + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Class for testing DefaultApi + /// + public sealed class DefaultApiTests : ApiTestsBase + { + private readonly IDefaultApi _instance; + + public DefaultApiTests(): base(Array.Empty()) + { + _instance = _host.Services.GetRequiredService(); + } + + /// + /// Test NowGet + /// + [Fact (Skip = "not implemented")] + public async Task NowGetAsyncTest() + { + var response = await _instance.NowGetAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs new file mode 100644 index 000000000000..3b09a6314ed2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -0,0 +1,103 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using System.Security.Cryptography; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Extensions; +using Xunit; + +namespace Org.OpenAPITools.Test.Api +{ + /// + /// Tests the dependency injection. + /// + public class DependencyInjectionTest + { + private readonly IHost _hostUsingConfigureWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + }) + .Build(); + + private readonly IHost _hostUsingConfigureWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureApi((context, services, options) => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }) + .Build(); + + private readonly IHost _hostUsingAddWithoutAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + }); + }) + .Build(); + + private readonly IHost _hostUsingAddWithAClient = + Host.CreateDefaultBuilder(Array.Empty()).ConfigureServices((host, services) => + { + services.AddApi(options => + { + + options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); + }); + }) + .Build(); + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithAClientTest() + { + var defaultApi = _hostUsingConfigureWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the configure method + /// + [Fact] + public void ConfigureApiWithoutAClientTest() + { + var defaultApi = _hostUsingConfigureWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithAClientTest() + { + var defaultApi = _hostUsingAddWithAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + + /// + /// Test dependency injection when using the add method + /// + [Fact] + public void AddApiWithoutAClientTest() + { + var defaultApi = _hostUsingAddWithoutAClient.Services.GetRequiredService(); + Assert.True(defaultApi.HttpClient.BaseAddress != null); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Model/NowGet200ResponseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Model/NowGet200ResponseTests.cs new file mode 100644 index 000000000000..920dfd9700ea --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Model/NowGet200ResponseTests.cs @@ -0,0 +1,74 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing NowGet200Response + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class NowGet200ResponseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for NowGet200Response + //private NowGet200Response instance; + + public NowGet200ResponseTests() + { + // TODO uncomment below to create an instance of NowGet200Response + //instance = new NowGet200Response(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of NowGet200Response + /// + [Fact] + public void NowGet200ResponseInstanceTest() + { + // TODO uncomment below to test "IsType" NowGet200Response + //Assert.IsType(instance); + } + + /// + /// Test the property 'Now' + /// + [Fact] + public void NowTest() + { + // TODO unit test for the property 'Now' + } + + /// + /// Test the property 'Today' + /// + [Fact] + public void TodayTest() + { + // TODO unit test for the property 'Today' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..5c6fff45e26c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,19 @@ + + + + Org.OpenAPITools.Test + Org.OpenAPITools.Test + net47 + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/README.md b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools.Test/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs new file mode 100644 index 000000000000..adb94299d245 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -0,0 +1,329 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text.Json; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; +using System.Diagnostics.CodeAnalysis; + +namespace Org.OpenAPITools.Api +{ + /// + /// Represents a collection of functions to interact with the API endpoints + /// This class is registered as transient. + /// + public interface IDefaultApi : IApi + { + /// + /// The class containing the events + /// + DefaultApiEvents Events { get; } + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task NowGetAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task NowGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + } + + /// + /// The + /// + public interface INowGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public class DefaultApiEvents + { + /// + /// The event raised after the server response + /// + public event EventHandler OnNowGet; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorNowGet; + + internal void ExecuteOnNowGet(DefaultApi.NowGetApiResponse apiResponse) + { + OnNowGet?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorNowGet(Exception exception) + { + OnErrorNowGet?.Invoke(this, new ExceptionEventArgs(exception)); + } + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public sealed partial class DefaultApi : IDefaultApi + { + private JsonSerializerOptions _jsonSerializerOptions; + + /// + /// The logger factory + /// + public ILoggerFactory LoggerFactory { get; } + + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The HttpClient + /// + public HttpClient HttpClient { get; } + + /// + /// The class containing the events + /// + public DefaultApiEvents Events { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public DefaultApi(ILogger logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents) + { + _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + LoggerFactory = loggerFactory; + Logger = LoggerFactory.CreateLogger(); + HttpClient = httpClient; + Events = defaultApiEvents; + } + + /// + /// Processes the server response + /// + /// + private void AfterNowGetDefaultImplementation(INowGetApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterNowGet(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterNowGet(ref bool suppressDefaultLog, INowGetApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorNowGetDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorNowGet(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorNowGet(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task NowGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await NowGetAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task NowGetAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/now"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + NowGetApiResponse apiResponseLocalVar = new NowGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/now", requestedAtLocalVar, _jsonSerializerOptions); + + AfterNowGetDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnNowGet(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorNowGetDefaultImplementation(e, "/now", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorNowGet(e); + throw; + } + } + + /// + /// The + /// + public partial class NowGetApiResponse : Org.OpenAPITools.Client.ApiResponse, INowGetApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public NowGetApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.NowGet200Response Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.NowGet200Response result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/IApi.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/IApi.cs new file mode 100644 index 000000000000..28520f043f2d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Api/IApi.cs @@ -0,0 +1,15 @@ +using System.Net.Http; + +namespace Org.OpenAPITools.Api +{ + /// + /// Any Api client + /// + public interface IApi + { + /// + /// The HttpClient + /// + HttpClient HttpClient { get; } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiException.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiException.cs new file mode 100644 index 000000000000..cf39d3c11d75 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiException.cs @@ -0,0 +1,50 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// API Exception + /// + public class ApiException : Exception + { + /// + /// The reason the api request failed + /// + public string ReasonPhrase { get; } + + /// + /// The HttpStatusCode + /// + public System.Net.HttpStatusCode StatusCode { get; } + + /// + /// The raw data returned by the api + /// + public string RawContent { get; } + + /// + /// Construct the ApiException from parts of the response + /// + /// + /// + /// + public ApiException(string reasonPhrase, System.Net.HttpStatusCode statusCode, string rawContent) : base(reasonPhrase ?? rawContent) + { + ReasonPhrase = reasonPhrase; + + StatusCode = statusCode; + + RawContent = rawContent; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiFactory.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiFactory.cs new file mode 100644 index 000000000000..b9b27c613f86 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiFactory.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; + +namespace Org.OpenAPITools.Client +{ + /// + /// An IApiFactory interface + /// + public interface IApiFactory + { + /// + /// A method to create an IApi of type IResult + /// + /// + /// + IResult Create() where IResult : IApi; + } + + /// + /// An ApiFactory + /// + public class ApiFactory : IApiFactory + { + /// + /// The service provider + /// + public IServiceProvider Services { get; } + + /// + /// Initializes a new instance of the class. + /// + /// + public ApiFactory(IServiceProvider services) + { + Services = services; + } + + /// + /// A method to create an IApi of type IResult + /// + /// + /// + public IResult Create() where IResult : IApi + { + return Services.GetRequiredService(); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs new file mode 100644 index 000000000000..3cb65e5adc0b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponseEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ApiResponseEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public ApiResponse ApiResponse { get; } + + /// + /// The ApiResponseEventArgs + /// + /// + public ApiResponseEventArgs(ApiResponse apiResponse) + { + ApiResponse = apiResponse; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs new file mode 100644 index 000000000000..c67dab81c948 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ApiResponse`1.cs @@ -0,0 +1,170 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Net; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a non-generic contract for the ApiResponse wrapper. + /// + public partial interface IApiResponse + { + /// + /// The IsSuccessStatusCode from the api response + /// + bool IsSuccessStatusCode { get; } + + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + HttpStatusCode StatusCode { get; } + + /// + /// The raw content of this response. + /// + string RawContent { get; } + + /// + /// The DateTime when the request was retrieved. + /// + DateTime DownloadedAt { get; } + + /// + /// The headers contained in the api response + /// + System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The path used when making the request. + /// + string Path { get; } + + /// + /// The reason phrase contained in the api response + /// + string ReasonPhrase { get; } + + /// + /// The DateTime when the request was sent. + /// + DateTime RequestedAt { get; } + + /// + /// The Uri used when making the request. + /// + Uri RequestUri { get; } + } + + /// + /// API Response + /// + public partial class ApiResponse : IApiResponse + { + /// + /// Gets the status code (HTTP status code) + /// + /// The status code. + public HttpStatusCode StatusCode { get; } + + /// + /// The raw data + /// + public string RawContent { get; protected set; } + + /// + /// The IsSuccessStatusCode from the api response + /// + public bool IsSuccessStatusCode { get; } + + /// + /// The reason phrase contained in the api response + /// + public string ReasonPhrase { get; } + + /// + /// The headers contained in the api response + /// + public System.Net.Http.Headers.HttpResponseHeaders Headers { get; } + + /// + /// The DateTime when the request was retrieved. + /// + public DateTime DownloadedAt { get; } = DateTime.UtcNow; + + /// + /// The DateTime when the request was sent. + /// + public DateTime RequestedAt { get; } + + /// + /// The path used when making the request. + /// + public string Path { get; } + + /// + /// The Uri used when making the request. + /// + public Uri RequestUri { get; } + + /// + /// The + /// + protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions; + + /// + /// Construct the response using an HttpResponseMessage + /// + /// + /// + /// + /// + /// + /// + public ApiResponse(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) + { + StatusCode = httpResponseMessage.StatusCode; + Headers = httpResponseMessage.Headers; + IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode; + ReasonPhrase = httpResponseMessage.ReasonPhrase; + RawContent = rawContent; + Path = path; + RequestUri = httpRequestMessage.RequestUri; + RequestedAt = requestedAt; + _jsonSerializerOptions = jsonSerializerOptions; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + } + + /// + /// An interface for responses of type + /// + /// + public interface IOk : IApiResponse + { + /// + /// Deserializes the response if the response is Ok + /// + /// + TType Ok(); + + /// + /// Returns true if the response is Ok and the deserialized response is not null + /// + /// + /// + bool TryOk(out TType result); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs new file mode 100644 index 000000000000..fc501e40444a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -0,0 +1,314 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.IO; +using System.Linq; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using Org.OpenAPITools.Model; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Org.OpenAPITools.Test")] + +namespace Org.OpenAPITools.Client +{ + /// + /// Utility functions providing some benefit to API client consumers. + /// + public static class ClientUtils + { + + /// + /// A delegate for events. + /// + /// + /// + /// + /// + public delegate void EventHandler(object sender, T e) where T : EventArgs; + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(string json, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(json, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Returns true when deserialization succeeds. + /// + /// + /// + /// + /// + /// + public static bool TryDeserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, out T result) + { + try + { + result = JsonSerializer.Deserialize(ref reader, options); + return result != null; + } + catch (Exception) + { + result = default; + return false; + } + } + + /// + /// Sanitize filename by removing the path + /// + /// Filename + /// Filename + public static string SanitizeFilename(string filename) + { + Match match = Regex.Match(filename, @".*[/\\](.*)$"); + return match.Success ? match.Groups[1].Value : filename; + } + + /// + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. + /// If parameter is a list, join the list with ",". + /// Otherwise just return the string. + /// + /// The parameter (header, path, query, form). + /// The DateTime serialization format. + /// Formatted string. + public static string ParameterToString(object obj, string format = ISO8601_DATETIME_FORMAT) + { + if (obj is DateTime dateTime) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTime.ToString(format); + if (obj is DateTimeOffset dateTimeOffset) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15T13:45:30.0000000 + return dateTimeOffset.ToString(format); + if (obj is bool boolean) + return boolean + ? "true" + : "false"; + if (obj is ICollection collection) + { + List entries = new List(); + foreach (var entry in collection) + entries.Add(ParameterToString(entry)); + return string.Join(",", entries); + } + + return Convert.ToString(obj, System.Globalization.CultureInfo.InvariantCulture); + } + + /// + /// URL encode a string + /// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 + /// + /// string to be URL encoded + /// Byte array + public static string UrlEncode(string input) + { + const int maxLength = 32766; + + if (input == null) + { + throw new ArgumentNullException("input"); + } + + if (input.Length <= maxLength) + { + return Uri.EscapeDataString(input); + } + + StringBuilder sb = new StringBuilder(input.Length * 2); + int index = 0; + + while (index < input.Length) + { + int length = Math.Min(input.Length - index, maxLength); + string subString = input.Substring(index, length); + + sb.Append(Uri.EscapeDataString(subString)); + index += subString.Length; + } + + return sb.ToString(); + } + + /// + /// Encode string in base64 format. + /// + /// string to be encoded. + /// Encoded string. + public static string Base64Encode(string text) + { + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + } + + /// + /// Convert stream to byte array + /// + /// Input stream to be converted + /// Byte array + public static byte[] ReadAsBytes(Stream inputStream) + { + using (var ms = new MemoryStream()) + { + inputStream.CopyTo(ms); + return ms.ToArray(); + } + } + + /// + /// Select the Content-Type header's value from the given content-type array: + /// if JSON type exists in the given array, use it; + /// otherwise use the first one defined in 'consumes' + /// + /// The Content-Type array to select from. + /// The Content-Type header to use. + public static string SelectHeaderContentType(string[] contentTypes) + { + if (contentTypes.Length == 0) + return null; + + foreach (var contentType in contentTypes) + { + if (IsJsonMime(contentType)) + return contentType; + } + + return contentTypes[0]; // use the first content type specified in 'consumes' + } + + /// + /// Select the Accept header's value from the given accepts array: + /// if JSON exists in the given array, use it; + /// otherwise use all of them (joining into a string) + /// + /// The accepts array to select from. + /// The Accept header to use. + public static string SelectHeaderAccept(string[] accepts) + { + if (accepts.Length == 0) + return null; + + if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase)) + return "application/json"; + + return string.Join(",", accepts); + } + + /// + /// Provides a case-insensitive check that a provided content type is a known JSON-like content type. + /// + public static readonly Regex JsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"); + + /// + /// Check if the given MIME is a JSON MIME. + /// JSON MIME examples: + /// application/json + /// application/json; charset=UTF8 + /// APPLICATION/JSON + /// application/vnd.company+json + /// + /// MIME + /// Returns True if MIME type is json. + public static bool IsJsonMime(string mime) + { + if (string.IsNullOrWhiteSpace(mime)) return false; + + return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); + } + + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string GetDiscriminator(Utf8JsonReader utf8JsonReader, string discriminator) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + if (localVarJsonPropertyName != null && localVarJsonPropertyName.Equals(discriminator)) + return utf8JsonReader.GetString(); + } + } + + throw new JsonException("The specified discriminator was not found."); + } + + /// + /// The base path of the API + /// + public const string BASE_ADDRESS = "http://localhost"; + + /// + /// The scheme of the API + /// + public const string SCHEME = "http"; + + /// + /// The context path of the API + /// + public const string CONTEXT_PATH = ""; + + /// + /// The host of the API + /// + public const string HOST = "localhost"; + + /// + /// The format to use for DateTime serialization + /// + public const string ISO8601_DATETIME_FORMAT = "o"; + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/CookieContainer.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/CookieContainer.cs new file mode 100644 index 000000000000..da94287dab88 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/CookieContainer.cs @@ -0,0 +1,18 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A class containing a CookieContainer + /// + public sealed class CookieContainer + { + /// + /// The collection of tokens + /// + public System.Net.CookieContainer Value { get; } = new System.Net.CookieContainer(); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs new file mode 100644 index 000000000000..52e971d082a7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeJsonConverter.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + throw new NotSupportedException(); + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + throw new NotSupportedException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) => + writer.WriteStringValue(dateTimeValue.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs new file mode 100644 index 000000000000..968d29161b12 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/DateTimeNullableJsonConverter.cs @@ -0,0 +1,82 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Org.OpenAPITools.Client +{ + /// + /// Formatter for 'date' and 'date-time' openapi formats ss defined by full-date - RFC3339 + /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types + /// + public class DateTimeNullableJsonConverter : JsonConverter + { + /// + /// The formats used to deserialize the date + /// + public static string[] Formats { get; } = { + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK", + "yyyy'-'MM'-'dd'T'HH':'mm':'ssK", + "yyyy'-'MM'-'dd", + "yyyyMMddTHHmmss.fffffffK", + "yyyyMMddTHHmmss.ffffffK", + "yyyyMMddTHHmmss.fffffK", + "yyyyMMddTHHmmss.ffffK", + "yyyyMMddTHHmmss.fffK", + "yyyyMMddTHHmmss.ffK", + "yyyyMMddTHHmmss.fK", + "yyyyMMddTHHmmssK", + "yyyyMMdd" + + }; + + /// + /// Returns a DateTime from the Json object + /// + /// + /// + /// + /// + public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + if (reader.TokenType == JsonTokenType.Null) + return null; + + string value = reader.GetString(); + + foreach(string format in Formats) + if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result)) + return result; + + return null; + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateTime? dateTimeValue, JsonSerializerOptions options) + { + if (dateTimeValue == null) + writer.WriteNullValue(); + else + writer.WriteStringValue(dateTimeValue.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", CultureInfo.InvariantCulture)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs new file mode 100644 index 000000000000..dcfab6678233 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/ExceptionEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// Useful for tracking server health + /// + public class ExceptionEventArgs : EventArgs + { + /// + /// The ApiResponse + /// + public Exception Exception { get; } + + /// + /// The ExcepetionEventArgs + /// + /// + public ExceptionEventArgs(Exception exception) + { + Exception = exception; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs new file mode 100644 index 000000000000..2eaac444e5ca --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -0,0 +1,129 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides hosting configuration for Org.OpenAPITools + /// + public class HostConfiguration + { + private readonly IServiceCollection _services; + private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions(); + + internal bool HttpClientsAdded { get; private set; } + + /// + /// Instantiates the class + /// + /// + public HostConfiguration(IServiceCollection services) + { + _services = services; + _jsonOptions.Converters.Add(new JsonStringEnumConverter()); + _jsonOptions.Converters.Add(new DateTimeJsonConverter()); + _jsonOptions.Converters.Add(new DateTimeNullableJsonConverter()); + _jsonOptions.Converters.Add(new NowGet200ResponseJsonConverter()); + JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); + _services.AddSingleton(jsonSerializerOptionsProvider); + _services.AddSingleton(); + _services.AddSingleton(); + _services.AddTransient(); + } + + /// + /// Configures the HttpClients. + /// + /// + /// + /// + public HostConfiguration AddApiHttpClients + ( + Action client = null, Action builder = null) + { + if (client == null) + client = c => c.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS); + + List builders = new List(); + + builders.Add(_services.AddHttpClient(client)); + + if (builder != null) + foreach (IHttpClientBuilder instance in builders) + builder(instance); + + HttpClientsAdded = true; + + return this; + } + + /// + /// Configures the JsonSerializerSettings + /// + /// + /// + public HostConfiguration ConfigureJsonOptions(Action options) + { + options(_jsonOptions); + + return this; + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(TTokenBase token) where TTokenBase : TokenBase + { + return AddTokens(new TTokenBase[]{ token }); + } + + /// + /// Adds tokens to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration AddTokens(IEnumerable tokens) where TTokenBase : TokenBase + { + TokenContainer container = new TokenContainer(tokens); + _services.AddSingleton(services => container); + + return this; + } + + /// + /// Adds a token provider to your IServiceCollection + /// + /// + /// + /// + public HostConfiguration UseProvider() + where TTokenProvider : TokenProvider + where TTokenBase : TokenBase + { + _services.AddSingleton(); + _services.AddSingleton>(services => services.GetRequiredService()); + + return this; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs new file mode 100644 index 000000000000..8fd6b68578f0 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/JsonSerializerOptionsProvider.cs @@ -0,0 +1,25 @@ +// + +using System.Text.Json; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides the JsonSerializerOptions + /// + public class JsonSerializerOptionsProvider + { + /// + /// the JsonSerializerOptions + /// + public JsonSerializerOptions Options { get; } + + /// + /// Instantiates a JsonSerializerOptionsProvider + /// + public JsonSerializerOptionsProvider(JsonSerializerOptions options) + { + Options = options; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/Option.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/Option.cs new file mode 100644 index 000000000000..2b34371084b5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/Option.cs @@ -0,0 +1,51 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +namespace Org.OpenAPITools.Client +{ + /// + /// A wrapper for operation parameters which are not required + /// + public struct Option + { + /// + /// The value to send to the server + /// + public TType Value { get; } + + /// + /// When true the value will be sent to the server + /// + internal bool IsSet { get; } + + /// + /// A wrapper for operation parameters which are not required + /// + /// + public Option(TType value) + { + IsSet = true; + Value = value; + } + + /// + /// Implicitly converts this option to the contained type + /// + /// + public static implicit operator TType(Option option) => option.Value; + + /// + /// Implicitly converts the provided value to an Option + /// + /// + public static implicit operator Option(TType value) => new Option(value); + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs new file mode 100644 index 000000000000..cddb84058868 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/RateLimitProvider`1.cs @@ -0,0 +1,55 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Channels; + +namespace Org.OpenAPITools.Client +{ + /// + /// Provides a token to the api clients. Tokens will be rate limited based on the provided TimeSpan. + /// + /// + public class RateLimitProvider : TokenProvider where TTokenBase : TokenBase + { + internal Dictionary> AvailableTokens { get; } = new Dictionary>(); + + /// + /// Instantiates a ThrottledTokenProvider. Your tokens will be rate limited based on the token's timeout. + /// + /// + public RateLimitProvider(TokenContainer container) : base(container.Tokens) + { + foreach(TTokenBase token in _tokens) + token.StartTimer(token.Timeout ?? TimeSpan.FromMilliseconds(40)); + + BoundedChannelOptions options = new BoundedChannelOptions(_tokens.Length) + { + FullMode = BoundedChannelFullMode.DropWrite + }; + + AvailableTokens.Add(string.Empty, Channel.CreateBounded(options)); + + foreach(Channel tokens in AvailableTokens.Values) + for (int i = 0; i < _tokens.Length; i++) + _tokens[i].TokenBecameAvailable += ((sender) => tokens.Writer.TryWrite((TTokenBase) sender)); + } + + internal override async System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default) + { + if (!AvailableTokens.TryGetValue(header, out Channel tokens)) + throw new KeyNotFoundException($"Could not locate a token for header '{header}'."); + + return await tokens.Reader.ReadAsync(cancellation).ConfigureAwait(false); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenBase.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenBase.cs new file mode 100644 index 000000000000..ec843104cafe --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenBase.cs @@ -0,0 +1,69 @@ +// + +using System; + +namespace Org.OpenAPITools.Client +{ + /// + /// The base for all tokens. + /// + public abstract class TokenBase + { + private DateTime _nextAvailable = DateTime.UtcNow; + private object _nextAvailableLock = new object(); + private readonly System.Timers.Timer _timer = new System.Timers.Timer(); + + + internal TimeSpan? Timeout { get; set; } + internal delegate void TokenBecameAvailableEventHandler(object sender); + internal event TokenBecameAvailableEventHandler TokenBecameAvailable; + + + /// + /// Initialize a TokenBase object. + /// + /// + internal TokenBase(TimeSpan? timeout = null) + { + Timeout = timeout; + + if (Timeout != null) + StartTimer(Timeout.Value); + } + + + /// + /// Starts the token's timer + /// + /// + internal void StartTimer(TimeSpan timeout) + { + Timeout = timeout; + _timer.Interval = Timeout.Value.TotalMilliseconds; + _timer.Elapsed += OnTimer; + _timer.AutoReset = true; + _timer.Start(); + } + + /// + /// Returns true while the token is rate limited. + /// + public bool IsRateLimited => _nextAvailable > DateTime.UtcNow; + + /// + /// Triggered when the server returns status code TooManyRequests + /// Once triggered the local timeout will be extended an arbitrary length of time. + /// + public void BeginRateLimit() + { + lock(_nextAvailableLock) + _nextAvailable = DateTime.UtcNow.AddSeconds(5); + } + + private void OnTimer(object sender, System.Timers.ElapsedEventArgs e) + { + if (TokenBecameAvailable != null && !IsRateLimited) + TokenBecameAvailable.Invoke(this); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenContainer`1.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenContainer`1.cs new file mode 100644 index 000000000000..ab372352e217 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenContainer`1.cs @@ -0,0 +1,35 @@ +// + +using System.Linq; +using System.Collections.Generic; + +namespace Org.OpenAPITools.Client +{ + /// + /// A container for a collection of tokens. + /// + /// + public sealed class TokenContainer where TTokenBase : TokenBase + { + /// + /// The collection of tokens + /// + public List Tokens { get; } = new List(); + + /// + /// Instantiates a TokenContainer + /// + public TokenContainer() + { + } + + /// + /// Instantiates a TokenContainer + /// + /// + public TokenContainer(System.Collections.Generic.IEnumerable tokens) + { + Tokens = tokens.ToList(); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenProvider`1.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenProvider`1.cs new file mode 100644 index 000000000000..069d52308681 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Client/TokenProvider`1.cs @@ -0,0 +1,42 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using System.Collections.Generic; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools +{ + /// + /// A class which will provide tokens. + /// + public abstract class TokenProvider where TTokenBase : TokenBase + { + /// + /// The array of tokens. + /// + protected TTokenBase[] _tokens; + + internal abstract System.Threading.Tasks.ValueTask GetAsync(string header = "", System.Threading.CancellationToken cancellation = default); + + /// + /// Instantiates a TokenProvider. + /// + /// + public TokenProvider(IEnumerable tokens) + { + _tokens = tokens.ToArray(); + + if (_tokens.Length == 0) + throw new ArgumentException("You did not provide any tokens."); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs new file mode 100644 index 000000000000..480524ee9c1f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHostBuilderExtensions.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHostBuilder + /// + public static class IHostBuilderExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static IHostBuilder ConfigureApi(this IHostBuilder builder, Action options) + { + builder.ConfigureServices((context, services) => + { + HostConfiguration config = new HostConfiguration(services); + + options(context, services, config); + + IServiceCollectionExtensions.AddApi(services, config); + }); + + return builder; + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs new file mode 100644 index 000000000000..2e45faf4463f --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IHttpClientBuilderExtensions.cs @@ -0,0 +1,77 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Timeout; +using Polly.Extensions.Http; +using Polly; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IHttpClientBuilder + /// + public static class IHttpClientBuilderExtensions + { + /// + /// Adds a Polly retry policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddRetryPolicy(this IHttpClientBuilder client, int retries) + { + client.AddPolicyHandler(RetryPolicy(retries)); + + return client; + } + + /// + /// Adds a Polly timeout policy to your clients. + /// + /// + /// + /// + public static IHttpClientBuilder AddTimeoutPolicy(this IHttpClientBuilder client, TimeSpan timeout) + { + client.AddPolicyHandler(TimeoutPolicy(timeout)); + + return client; + } + + /// + /// Adds a Polly circuit breaker to your clients. + /// + /// + /// + /// + /// + public static IHttpClientBuilder AddCircuitBreakerPolicy(this IHttpClientBuilder client, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + { + client.AddTransientHttpErrorPolicy(builder => CircuitBreakerPolicy(builder, handledEventsAllowedBeforeBreaking, durationOfBreak)); + + return client; + } + + private static Polly.Retry.AsyncRetryPolicy RetryPolicy(int retries) + => HttpPolicyExtensions + .HandleTransientHttpError() + .Or() + .RetryAsync(retries); + + private static AsyncTimeoutPolicy TimeoutPolicy(TimeSpan timeout) + => Policy.TimeoutAsync(timeout); + + private static Polly.CircuitBreaker.AsyncCircuitBreakerPolicy CircuitBreakerPolicy( + PolicyBuilder builder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak) + => builder.CircuitBreakerAsync(handledEventsAllowedBeforeBreaking, durationOfBreak); + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 000000000000..d469c015da98 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,71 @@ +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Extensions +{ + /// + /// Extension methods for IServiceCollection + /// + public static class IServiceCollectionExtensions + { + /// + /// Add the api to your host builder. + /// + /// + public static void AddApi(this IServiceCollection services) + { + HostConfiguration config = new HostConfiguration(services); + AddApi(services, config); + } + + /// + /// Add the api to your host builder. + /// + /// + /// + public static void AddApi(this IServiceCollection services, Action options) + { + HostConfiguration config = new HostConfiguration(services); + options(config); + AddApi(services, config); + } + + internal static void AddApi(IServiceCollection services, HostConfiguration host) + { + if (!host.HttpClientsAdded) + host.AddApiHttpClients(); + + services.AddSingleton(); + + // ensure that a token provider was provided for this token type + // if not, default to RateLimitProvider + var containerServices = services.Where(s => s.ServiceType.IsGenericType && + s.ServiceType.GetGenericTypeDefinition().IsAssignableFrom(typeof(TokenContainer<>))).ToArray(); + + foreach(var containerService in containerServices) + { + var tokenType = containerService.ServiceType.GenericTypeArguments[0]; + + var provider = services.FirstOrDefault(s => s.ServiceType.IsAssignableFrom(typeof(TokenProvider<>).MakeGenericType(tokenType))); + + if (provider == null) + { + services.AddSingleton(typeof(RateLimitProvider<>).MakeGenericType(tokenType)); + services.AddSingleton(typeof(TokenProvider<>).MakeGenericType(tokenType), + s => s.GetRequiredService(typeof(RateLimitProvider<>).MakeGenericType(tokenType))); + } + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs new file mode 100644 index 000000000000..1a5e14864026 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs @@ -0,0 +1,201 @@ +// +/* + * OpenAPI Dates + * + * Thic spec contains endpoints with dates in different formats + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// NowGet200Response + /// + public partial class NowGet200Response : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// now + /// today + [JsonConstructor] + public NowGet200Response(Option now = default, Option today = default) + { + NowOption = now; + TodayOption = today; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Now + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option NowOption { get; private set; } + + /// + /// Gets or Sets Now + /// + [JsonPropertyName("now")] + public DateTime? Now { get { return this.NowOption; } set { this.NowOption = new Option(value); } } + + /// + /// Used to track the state of Today + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option TodayOption { get; private set; } + + /// + /// Gets or Sets Today + /// + [JsonPropertyName("today")] + public DateTime? Today { get { return this.TodayOption; } set { this.TodayOption = new Option(value); } } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class NowGet200Response {\n"); + sb.Append(" Now: ").Append(Now).Append("\n"); + sb.Append(" Today: ").Append(Today).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class NowGet200ResponseJsonConverter : JsonConverter + { + /// + /// The format to use to serialize Now + /// + public static string NowFormat { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; + + /// + /// The format to use to serialize Today + /// + public static string TodayFormat { get; set; } = "yyyy'-'MM'-'dd"; + + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override NowGet200Response Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option now = default; + Option today = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "now": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + now = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "today": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + today = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (now.IsSet && now.Value == null) + throw new ArgumentNullException(nameof(now), "Property is not nullable for class NowGet200Response."); + + if (today.IsSet && today.Value == null) + throw new ArgumentNullException(nameof(today), "Property is not nullable for class NowGet200Response."); + + return new NowGet200Response(now, today); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, nowGet200Response, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions) + { + if (nowGet200Response.NowOption.IsSet) + writer.WriteString("now", nowGet200Response.NowOption.Value.Value.ToString(NowFormat)); + + if (nowGet200Response.TodayOption.IsSet) + writer.WriteString("today", nowGet200Response.TodayOption.Value.Value.ToString(TodayFormat)); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Org.OpenAPITools.csproj new file mode 100644 index 000000000000..201640a24d33 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,32 @@ + + + + true + net47 + Org.OpenAPITools + Org.OpenAPITools + Library + OpenAPI + OpenAPI + OpenAPI Library + A library generated from a OpenAPI doc + No Copyright + Org.OpenAPITools + 1.0.0 + bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml + https://github.com/GIT_USER_ID/GIT_REPO_ID.git + git + Minor update + false + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/README.md new file mode 100644 index 000000000000..bb59c99e6fd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/UseDateTimeForDate/src/Org.OpenAPITools/README.md @@ -0,0 +1,176 @@ +# Created with Openapi Generator + + +## Run the following powershell command to generate the library + +```ps1 +$properties = @( + 'apiName=Api', + 'targetFramework=net47', + 'validatable=true', + 'nullableReferenceTypes=', + 'hideGenerationTimestamp=true', + 'packageVersion=1.0.0', + 'packageAuthors=OpenAPI', + 'packageCompany=OpenAPI', + 'packageCopyright=No Copyright', + 'packageDescription=A library generated from a OpenAPI doc', + 'packageName=Org.OpenAPITools', + 'packageTags=', + 'packageTitle=OpenAPI Library' +) -join "," + +$global = @( + 'apiDocs=true', + 'modelDocs=true', + 'apiTests=true', + 'modelTests=true' +) -join "," + +java -jar "/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate ` + -g csharp-netcore ` + -i .yaml ` + -o ` + --library generichost ` + --additional-properties $properties ` + --global-property $global ` + --git-host "github.com" ` + --git-repo-id "GIT_REPO_ID" ` + --git-user-id "GIT_USER_ID" ` + --release-note "Minor update" + # -t templates +``` + + +## Using the library in your project + +```cs +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace YourProject +{ + public class Program + { + public static async Task Main(string[] args) + { + var host = CreateHostBuilder(args).Build(); + var api = host.Services.GetRequiredService(); + NowGetApiResponse apiResponse = await api.NowGetAsync("todo"); + NowGet200Response model = apiResponse.Ok(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .ConfigureApi((context, options) => + { + options.ConfigureJsonOptions((jsonOptions) => + { + // your custom converters if any + }); + + options.AddApiHttpClients(builder: builder => builder + .AddRetryPolicy(2) + .AddTimeoutPolicy(TimeSpan.FromSeconds(5)) + .AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30)) + // add whatever middleware you prefer + ); + }); + } +} +``` + +## Questions + +- What about HttpRequest failures and retries? + If supportsRetry is enabled, you can configure Polly in the ConfigureClients method. +- How are tokens used? + Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting. + Other providers can be used with the UseProvider method. +- Does an HttpRequest throw an error when the server response is not Ok? + It depends how you made the request. If the return type is ApiResponse no error will be thrown, though the Content property will be null. + StatusCode and ReasonPhrase will contain information about the error. + If the return type is T, then it will throw. If the return type is TOrDefault, it will return null. +- How do I validate requests and process responses? + Use the provided On and After methods in the Api class from the namespace Org.OpenAPITools.Rest.DefaultApi. + Or provide your own class by using the generic ConfigureApi method. + + +## Dependencies + +- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later +- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later +- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later +- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later + + +## Documentation for Authorization + +Endpoints do not require authorization. + + +## Build +- SDK version: 1.0.0 +- Generator version: 7.7.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CSharpClientCodegen + +## Api Information +- appName: OpenAPI Dates +- appVersion: 1.0.0 +- appDescription: Thic spec contains endpoints with dates in different formats + +## [OpenApi Global properties](https://openapi-generator.tech/docs/globals) +- generateAliasAsModel: +- supportingFiles: +- models: omitted for brevity +- apis: omitted for brevity +- apiDocs: true +- modelDocs: true +- apiTests: true +- modelTests: true + +## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore) +- allowUnicodeIdentifiers: +- apiName: Api +- caseInsensitiveResponseHeaders: +- conditionalSerialization: false +- disallowAdditionalPropertiesIfNotPresent: +- gitHost: github.com +- gitRepoId: GIT_REPO_ID +- gitUserId: GIT_USER_ID +- hideGenerationTimestamp: true +- interfacePrefix: I +- library: generichost +- licenseId: +- modelPropertyNaming: +- netCoreProjectFile: false +- nonPublicApi: false +- nullableReferenceTypes: +- optionalAssemblyInfo: +- optionalEmitDefaultValues: false +- optionalMethodArgument: true +- optionalProjectFile: +- packageAuthors: OpenAPI +- packageCompany: OpenAPI +- packageCopyright: No Copyright +- packageDescription: A library generated from a OpenAPI doc +- packageGuid: {2E60EF87-DB0B-4D01-A36E-F5E90F7EC757} +- packageName: Org.OpenAPITools +- packageTags: +- packageTitle: OpenAPI Library +- packageVersion: 1.0.0 +- releaseNote: Minor update +- returnICollection: false +- sortParamsByRequiredFlag: +- sourceFolder: src +- targetFramework: net47 +- useCollection: false +- useDateTimeOffset: false +- useOneOfDiscriminatorLookup: false +- validatable: true + +This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.