From ede6458d197b047710eedc53d1fec3219b32ba7c Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Tue, 21 May 2024 02:32:12 -0400 Subject: [PATCH] [csharp][generichost] Remove discriminator property (#18445) * fixed nullability * minor refactor to address a comment * removed discriminator property * update more manual tests * update more manual tests * added tests and bug fixes * fixed allof * reworked manual tests to compare json instead of classes, reworked discriminator logic * removed unneeded code --- .../openapitools/codegen/DefaultCodegen.java | 13 +- .../generichost/ClientUtils.mustache | 37 ++++ .../generichost/JsonConverter.mustache | 49 ++++- .../generichost/ModelBaseSignature.mustache | 2 +- .../generichost/ModelSignature.mustache | 2 +- .../generichost/modelGeneric.mustache | 27 +++ .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../AllOf/src/Org.OpenAPITools/Model/Adult.cs | 22 ++- .../AllOf/src/Org.OpenAPITools/Model/Child.cs | 22 ++- .../src/Org.OpenAPITools/Model/Person.cs | 45 +++-- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../AnyOf/src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../AnyOf/src/Org.OpenAPITools/Model/Fruit.cs | 8 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 8 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Activity.cs | 4 +- .../ActivityOutputElementRepresentation.cs | 4 +- .../Model/AdditionalPropertiesClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Animal.cs | 39 ++-- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 4 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 4 +- .../Model/ArrayOfNumberOnly.cs | 4 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 4 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 4 +- .../Org.OpenAPITools/Model/Capitalization.cs | 4 +- .../src/Org.OpenAPITools/Model/Cat.cs | 19 +- .../src/Org.OpenAPITools/Model/Category.cs | 4 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 21 +-- .../src/Org.OpenAPITools/Model/ClassModel.cs | 4 +- .../Model/ComplexQuadrilateral.cs | 4 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 4 +- .../Org.OpenAPITools/Model/DateOnlyClass.cs | 4 +- .../Model/DeprecatedObject.cs | 4 +- .../src/Org.OpenAPITools/Model/Dog.cs | 19 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 4 +- .../Model/EquilateralTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/File.cs | 4 +- .../Model/FileSchemaTestClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Foo.cs | 4 +- .../Model/FooGetDefaultResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../src/Org.OpenAPITools/Model/FruitReq.cs | 4 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 8 +- .../Model/GrandparentAnimal.cs | 39 ++-- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 4 +- .../Model/HealthCheckResult.cs | 4 +- .../Model/IsoscelesTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/List.cs | 4 +- .../Model/LiteralStringClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 38 ++-- .../src/Org.OpenAPITools/Model/MapTest.cs | 4 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 4 +- .../Model/Model200Response.cs | 4 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 4 +- .../src/Org.OpenAPITools/Model/Name.cs | 4 +- ...cationtestGetElementsV1ResponseMPayload.cs | 4 +- .../Org.OpenAPITools/Model/NullableClass.cs | 4 +- .../Model/NullableGuidClass.cs | 4 +- .../Org.OpenAPITools/Model/NullableShape.cs | 30 +-- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 4 +- .../Model/ObjectWithDeprecatedFields.cs | 4 +- .../src/Org.OpenAPITools/Model/OneOfString.cs | 4 +- .../src/Org.OpenAPITools/Model/Order.cs | 4 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 4 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 29 ++- .../src/Org.OpenAPITools/Model/Pet.cs | 4 +- .../src/Org.OpenAPITools/Model/Pig.cs | 30 +-- .../Model/PolymorphicProperty.cs | 4 +- .../Org.OpenAPITools/Model/Quadrilateral.cs | 30 +-- .../Model/QuadrilateralInterface.cs | 4 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 4 +- .../Org.OpenAPITools/Model/RequiredClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Return.cs | 4 +- .../Model/RolesReportsHash.cs | 4 +- .../Model/RolesReportsHashRole.cs | 4 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/Shape.cs | 30 +-- .../Org.OpenAPITools/Model/ShapeInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 30 +-- .../Model/SimpleQuadrilateral.cs | 4 +- .../Model/SpecialModelName.cs | 4 +- .../src/Org.OpenAPITools/Model/Tag.cs | 4 +- .../Model/TestCollectionEndingWithWordList.cs | 4 +- .../TestCollectionEndingWithWordListObject.cs | 4 +- ...lineFreeformAdditionalPropertiesRequest.cs | 4 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 38 ++-- .../Model/TriangleInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/User.cs | 4 +- .../src/Org.OpenAPITools/Model/Whale.cs | 4 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 4 +- .../Model/ZeroBasedEnumClass.cs | 4 +- .../UnitTest1.cs | 166 ++++++++++------ .../UnitTest1.cs | 178 +++++++++++------- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Activity.cs | 4 +- .../ActivityOutputElementRepresentation.cs | 4 +- .../Model/AdditionalPropertiesClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Animal.cs | 39 ++-- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 4 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 4 +- .../Model/ArrayOfNumberOnly.cs | 4 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 4 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 4 +- .../Org.OpenAPITools/Model/Capitalization.cs | 4 +- .../src/Org.OpenAPITools/Model/Cat.cs | 19 +- .../src/Org.OpenAPITools/Model/Category.cs | 4 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 27 ++- .../src/Org.OpenAPITools/Model/ClassModel.cs | 4 +- .../Model/ComplexQuadrilateral.cs | 4 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 4 +- .../Org.OpenAPITools/Model/DateOnlyClass.cs | 4 +- .../Model/DeprecatedObject.cs | 4 +- .../src/Org.OpenAPITools/Model/Dog.cs | 19 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 4 +- .../Model/EquilateralTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/File.cs | 4 +- .../Model/FileSchemaTestClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Foo.cs | 4 +- .../Model/FooGetDefaultResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../src/Org.OpenAPITools/Model/FruitReq.cs | 4 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 8 +- .../Model/GrandparentAnimal.cs | 39 ++-- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 4 +- .../Model/HealthCheckResult.cs | 4 +- .../Model/IsoscelesTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/List.cs | 4 +- .../Model/LiteralStringClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 38 ++-- .../src/Org.OpenAPITools/Model/MapTest.cs | 4 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 4 +- .../Model/Model200Response.cs | 4 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 4 +- .../src/Org.OpenAPITools/Model/Name.cs | 4 +- ...cationtestGetElementsV1ResponseMPayload.cs | 4 +- .../Org.OpenAPITools/Model/NullableClass.cs | 4 +- .../Model/NullableGuidClass.cs | 4 +- .../Org.OpenAPITools/Model/NullableShape.cs | 30 +-- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 4 +- .../Model/ObjectWithDeprecatedFields.cs | 4 +- .../src/Org.OpenAPITools/Model/OneOfString.cs | 4 +- .../src/Org.OpenAPITools/Model/Order.cs | 4 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 4 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 29 ++- .../src/Org.OpenAPITools/Model/Pet.cs | 4 +- .../src/Org.OpenAPITools/Model/Pig.cs | 30 +-- .../Model/PolymorphicProperty.cs | 4 +- .../Org.OpenAPITools/Model/Quadrilateral.cs | 30 +-- .../Model/QuadrilateralInterface.cs | 4 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 4 +- .../Org.OpenAPITools/Model/RequiredClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Return.cs | 4 +- .../Model/RolesReportsHash.cs | 4 +- .../Model/RolesReportsHashRole.cs | 4 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/Shape.cs | 30 +-- .../Org.OpenAPITools/Model/ShapeInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 30 +-- .../Model/SimpleQuadrilateral.cs | 4 +- .../Model/SpecialModelName.cs | 4 +- .../src/Org.OpenAPITools/Model/Tag.cs | 4 +- .../Model/TestCollectionEndingWithWordList.cs | 4 +- .../TestCollectionEndingWithWordListObject.cs | 4 +- ...lineFreeformAdditionalPropertiesRequest.cs | 4 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 38 ++-- .../Model/TriangleInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/User.cs | 4 +- .../src/Org.OpenAPITools/Model/Whale.cs | 4 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 4 +- .../Model/ZeroBasedEnumClass.cs | 4 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../OneOf/src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../OneOf/src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Activity.cs | 4 +- .../ActivityOutputElementRepresentation.cs | 4 +- .../Model/AdditionalPropertiesClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Animal.cs | 39 ++-- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 4 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 4 +- .../Model/ArrayOfNumberOnly.cs | 4 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 4 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 4 +- .../Org.OpenAPITools/Model/Capitalization.cs | 4 +- .../src/Org.OpenAPITools/Model/Cat.cs | 19 +- .../src/Org.OpenAPITools/Model/Category.cs | 4 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 27 ++- .../src/Org.OpenAPITools/Model/ClassModel.cs | 4 +- .../Model/ComplexQuadrilateral.cs | 4 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 4 +- .../Org.OpenAPITools/Model/DateOnlyClass.cs | 4 +- .../Model/DeprecatedObject.cs | 4 +- .../src/Org.OpenAPITools/Model/Dog.cs | 19 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 4 +- .../Model/EquilateralTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/File.cs | 4 +- .../Model/FileSchemaTestClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Foo.cs | 4 +- .../Model/FooGetDefaultResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../src/Org.OpenAPITools/Model/FruitReq.cs | 4 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 8 +- .../Model/GrandparentAnimal.cs | 39 ++-- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 4 +- .../Model/HealthCheckResult.cs | 4 +- .../Model/IsoscelesTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/List.cs | 4 +- .../Model/LiteralStringClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 38 ++-- .../src/Org.OpenAPITools/Model/MapTest.cs | 4 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 4 +- .../Model/Model200Response.cs | 4 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 4 +- .../src/Org.OpenAPITools/Model/Name.cs | 4 +- ...cationtestGetElementsV1ResponseMPayload.cs | 4 +- .../Org.OpenAPITools/Model/NullableClass.cs | 4 +- .../Model/NullableGuidClass.cs | 4 +- .../Org.OpenAPITools/Model/NullableShape.cs | 30 +-- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 4 +- .../Model/ObjectWithDeprecatedFields.cs | 4 +- .../src/Org.OpenAPITools/Model/OneOfString.cs | 4 +- .../src/Org.OpenAPITools/Model/Order.cs | 4 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 4 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 29 ++- .../src/Org.OpenAPITools/Model/Pet.cs | 4 +- .../src/Org.OpenAPITools/Model/Pig.cs | 30 +-- .../Model/PolymorphicProperty.cs | 4 +- .../Org.OpenAPITools/Model/Quadrilateral.cs | 30 +-- .../Model/QuadrilateralInterface.cs | 4 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 4 +- .../Org.OpenAPITools/Model/RequiredClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Return.cs | 4 +- .../Model/RolesReportsHash.cs | 4 +- .../Model/RolesReportsHashRole.cs | 4 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/Shape.cs | 30 +-- .../Org.OpenAPITools/Model/ShapeInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 30 +-- .../Model/SimpleQuadrilateral.cs | 4 +- .../Model/SpecialModelName.cs | 4 +- .../src/Org.OpenAPITools/Model/Tag.cs | 4 +- .../Model/TestCollectionEndingWithWordList.cs | 4 +- .../TestCollectionEndingWithWordListObject.cs | 4 +- ...lineFreeformAdditionalPropertiesRequest.cs | 4 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 38 ++-- .../Model/TriangleInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/User.cs | 4 +- .../src/Org.OpenAPITools/Model/Whale.cs | 4 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 4 +- .../Model/ZeroBasedEnumClass.cs | 4 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Activity.cs | 4 +- .../ActivityOutputElementRepresentation.cs | 4 +- .../Model/AdditionalPropertiesClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Animal.cs | 39 ++-- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 4 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 4 +- .../Model/ArrayOfNumberOnly.cs | 4 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 4 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 4 +- .../Org.OpenAPITools/Model/Capitalization.cs | 4 +- .../src/Org.OpenAPITools/Model/Cat.cs | 19 +- .../src/Org.OpenAPITools/Model/Category.cs | 4 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 27 ++- .../src/Org.OpenAPITools/Model/ClassModel.cs | 4 +- .../Model/ComplexQuadrilateral.cs | 4 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 4 +- .../Org.OpenAPITools/Model/DateOnlyClass.cs | 4 +- .../Model/DeprecatedObject.cs | 4 +- .../src/Org.OpenAPITools/Model/Dog.cs | 19 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 4 +- .../Model/EquilateralTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/File.cs | 4 +- .../Model/FileSchemaTestClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Foo.cs | 4 +- .../Model/FooGetDefaultResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../src/Org.OpenAPITools/Model/FruitReq.cs | 4 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 8 +- .../Model/GrandparentAnimal.cs | 39 ++-- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 4 +- .../Model/HealthCheckResult.cs | 4 +- .../Model/IsoscelesTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/List.cs | 4 +- .../Model/LiteralStringClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 38 ++-- .../src/Org.OpenAPITools/Model/MapTest.cs | 4 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 4 +- .../Model/Model200Response.cs | 4 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 4 +- .../src/Org.OpenAPITools/Model/Name.cs | 4 +- ...cationtestGetElementsV1ResponseMPayload.cs | 4 +- .../Org.OpenAPITools/Model/NullableClass.cs | 4 +- .../Model/NullableGuidClass.cs | 4 +- .../Org.OpenAPITools/Model/NullableShape.cs | 30 +-- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 4 +- .../Model/ObjectWithDeprecatedFields.cs | 4 +- .../src/Org.OpenAPITools/Model/OneOfString.cs | 4 +- .../src/Org.OpenAPITools/Model/Order.cs | 4 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 4 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 29 ++- .../src/Org.OpenAPITools/Model/Pet.cs | 4 +- .../src/Org.OpenAPITools/Model/Pig.cs | 30 +-- .../Model/PolymorphicProperty.cs | 4 +- .../Org.OpenAPITools/Model/Quadrilateral.cs | 30 +-- .../Model/QuadrilateralInterface.cs | 4 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 4 +- .../Org.OpenAPITools/Model/RequiredClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Return.cs | 4 +- .../Model/RolesReportsHash.cs | 4 +- .../Model/RolesReportsHashRole.cs | 4 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/Shape.cs | 30 +-- .../Org.OpenAPITools/Model/ShapeInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 30 +-- .../Model/SimpleQuadrilateral.cs | 4 +- .../Model/SpecialModelName.cs | 4 +- .../src/Org.OpenAPITools/Model/Tag.cs | 4 +- .../Model/TestCollectionEndingWithWordList.cs | 4 +- .../TestCollectionEndingWithWordListObject.cs | 4 +- ...lineFreeformAdditionalPropertiesRequest.cs | 4 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 38 ++-- .../Model/TriangleInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/User.cs | 4 +- .../src/Org.OpenAPITools/Model/Whale.cs | 4 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 4 +- .../Model/ZeroBasedEnumClass.cs | 4 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../Model/NowGet200Response.cs | 4 +- .../Org.OpenAPITools/Client/ClientUtils.cs | 37 ++++ .../src/Org.OpenAPITools/Model/Activity.cs | 4 +- .../ActivityOutputElementRepresentation.cs | 4 +- .../Model/AdditionalPropertiesClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Animal.cs | 39 ++-- .../src/Org.OpenAPITools/Model/ApiResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/Apple.cs | 4 +- .../src/Org.OpenAPITools/Model/AppleReq.cs | 4 +- .../Model/ArrayOfArrayOfNumberOnly.cs | 4 +- .../Model/ArrayOfNumberOnly.cs | 4 +- .../src/Org.OpenAPITools/Model/ArrayTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Banana.cs | 4 +- .../src/Org.OpenAPITools/Model/BananaReq.cs | 4 +- .../src/Org.OpenAPITools/Model/BasquePig.cs | 4 +- .../Org.OpenAPITools/Model/Capitalization.cs | 4 +- .../src/Org.OpenAPITools/Model/Cat.cs | 19 +- .../src/Org.OpenAPITools/Model/Category.cs | 4 +- .../src/Org.OpenAPITools/Model/ChildCat.cs | 27 ++- .../src/Org.OpenAPITools/Model/ClassModel.cs | 4 +- .../Model/ComplexQuadrilateral.cs | 4 +- .../src/Org.OpenAPITools/Model/DanishPig.cs | 4 +- .../Org.OpenAPITools/Model/DateOnlyClass.cs | 4 +- .../Model/DeprecatedObject.cs | 4 +- .../src/Org.OpenAPITools/Model/Dog.cs | 19 +- .../src/Org.OpenAPITools/Model/Drawing.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumArrays.cs | 4 +- .../src/Org.OpenAPITools/Model/EnumTest.cs | 4 +- .../Model/EquilateralTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/File.cs | 4 +- .../Model/FileSchemaTestClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Foo.cs | 4 +- .../Model/FooGetDefaultResponse.cs | 4 +- .../src/Org.OpenAPITools/Model/FormatTest.cs | 4 +- .../src/Org.OpenAPITools/Model/Fruit.cs | 4 +- .../src/Org.OpenAPITools/Model/FruitReq.cs | 4 +- .../src/Org.OpenAPITools/Model/GmFruit.cs | 8 +- .../Model/GrandparentAnimal.cs | 39 ++-- .../Org.OpenAPITools/Model/HasOnlyReadOnly.cs | 4 +- .../Model/HealthCheckResult.cs | 4 +- .../Model/IsoscelesTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/List.cs | 4 +- .../Model/LiteralStringClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Mammal.cs | 38 ++-- .../src/Org.OpenAPITools/Model/MapTest.cs | 4 +- ...dPropertiesAndAdditionalPropertiesClass.cs | 4 +- .../Model/Model200Response.cs | 4 +- .../src/Org.OpenAPITools/Model/ModelClient.cs | 4 +- .../src/Org.OpenAPITools/Model/Name.cs | 4 +- ...cationtestGetElementsV1ResponseMPayload.cs | 4 +- .../Org.OpenAPITools/Model/NullableClass.cs | 4 +- .../Model/NullableGuidClass.cs | 4 +- .../Org.OpenAPITools/Model/NullableShape.cs | 30 +-- .../src/Org.OpenAPITools/Model/NumberOnly.cs | 4 +- .../Model/ObjectWithDeprecatedFields.cs | 4 +- .../src/Org.OpenAPITools/Model/OneOfString.cs | 4 +- .../src/Org.OpenAPITools/Model/Order.cs | 4 +- .../Org.OpenAPITools/Model/OuterComposite.cs | 4 +- .../src/Org.OpenAPITools/Model/ParentPet.cs | 29 ++- .../src/Org.OpenAPITools/Model/Pet.cs | 4 +- .../src/Org.OpenAPITools/Model/Pig.cs | 30 +-- .../Model/PolymorphicProperty.cs | 4 +- .../Org.OpenAPITools/Model/Quadrilateral.cs | 30 +-- .../Model/QuadrilateralInterface.cs | 4 +- .../Org.OpenAPITools/Model/ReadOnlyFirst.cs | 4 +- .../Org.OpenAPITools/Model/RequiredClass.cs | 4 +- .../src/Org.OpenAPITools/Model/Return.cs | 4 +- .../Model/RolesReportsHash.cs | 4 +- .../Model/RolesReportsHashRole.cs | 4 +- .../Org.OpenAPITools/Model/ScaleneTriangle.cs | 4 +- .../src/Org.OpenAPITools/Model/Shape.cs | 30 +-- .../Org.OpenAPITools/Model/ShapeInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/ShapeOrNull.cs | 30 +-- .../Model/SimpleQuadrilateral.cs | 4 +- .../Model/SpecialModelName.cs | 4 +- .../src/Org.OpenAPITools/Model/Tag.cs | 4 +- .../Model/TestCollectionEndingWithWordList.cs | 4 +- .../TestCollectionEndingWithWordListObject.cs | 4 +- ...lineFreeformAdditionalPropertiesRequest.cs | 4 +- .../src/Org.OpenAPITools/Model/Triangle.cs | 38 ++-- .../Model/TriangleInterface.cs | 4 +- .../src/Org.OpenAPITools/Model/User.cs | 4 +- .../src/Org.OpenAPITools/Model/Whale.cs | 4 +- .../src/Org.OpenAPITools/Model/Zebra.cs | 4 +- .../Model/ZeroBasedEnumClass.cs | 4 +- 446 files changed, 2328 insertions(+), 2057 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 9ffdfefd2b78..0682fe7c099b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -589,10 +589,21 @@ public Map postProcessAllModels(Map objs) return objs; } + /** + * A property is new if it is in a derived class and the derived property is different. + * This usually occurs when the data type is different. + * We can also consider discriminators as new because the derived class discriminator will have to be defined again + * to contain a new value. Doing so prevents having to include the discriminator in the constructor. + * @param model + * @param property + * @return + */ private boolean codegenPropertyIsNew(CodegenModel model, CodegenProperty property) { return model.parentModel == null ? false - : model.parentModel.allVars.stream().anyMatch(p -> p.name.equals(property.name) && (p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false)); + : model.parentModel.allVars.stream().anyMatch(p -> + p.name.equals(property.name) && + (p.dataType.equals(property.dataType) == false || p.datatypeWithEnum.equals(property.datatypeWithEnum) == false || p.isDiscriminator)); } /** 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 ae83297b1d50..d2917e451950 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 @@ -336,6 +336,43 @@ using System.Runtime.CompilerServices; return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); } + /// + /// Get the discriminator + /// + /// + /// + /// + /// + public static string{{nrt?}} 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{{nrt?}} 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 /// diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache index 067a6f9b64ca..2b8fe63b201e 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache @@ -44,6 +44,17 @@ {{/-last}} {{/allVars}} + {{#discriminator}} + {{#children}} + {{#-first}} + string{{nrt?}} discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "{{discriminator.propertyBaseName}}"); + + {{/-first}} + if (discriminator != null && discriminator.Equals("{{name}}")) + return JsonSerializer.Deserialize<{{{name}}}>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + {{/children}} + {{/discriminator}} {{#model.discriminator}} {{#model.hasDiscriminatorWithNonEmptyMapping}} {{#mappedModels}} @@ -281,7 +292,7 @@ {{#model.hasDiscriminatorWithNonEmptyMapping}} {{#mappedModels}} if ({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}} != null) - return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); + return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}}); {{#-last}} throw new JsonException(); @@ -300,14 +311,14 @@ {{/-last}} {{/required}} - return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); + return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}}); {{/composedSchemas.oneOf}} {{^model.discriminator}} {{#composedSchemas}} {{#oneOf}} {{^vendorExtensions.x-duplicated-data-type}} if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} != null) - return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}}); + return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/isDiscriminator}}{{/allVars}}{{/lambda.joinWithComma}}); {{/vendorExtensions.x-duplicated-data-type}} {{#-last}} @@ -331,6 +342,18 @@ public override void Write(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions) { {{#lambda.trimLineBreaks}} + {{#lambda.copy}} + {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}} + {{/lambda.copy}} + {{#discriminator}} + {{#children}} + if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} is {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}){ + JsonSerializer.Serialize<{{{name}}}>(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions); + return; + } + + {{/children}} + {{/discriminator}} writer.WriteStartObject(); {{#model.discriminator}} @@ -339,7 +362,7 @@ {{^vendorExtensions.x-duplicated-data-type}} if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} != null) { {{baseType}}JsonConverter {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}} = ({{baseType}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}.GetType())); - {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}}.WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}, jsonSerializerOptions); + {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}}.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}, jsonSerializerOptions); } {{/vendorExtensions.x-duplicated-data-type}} @@ -352,13 +375,13 @@ if ({{#lambda.joinWithAmpersand}}{{^required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet {{/required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}} != null{{/lambda.joinWithAmpersand}}) { {{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType())); - {{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions); + {{datatypeWithEnum}}JsonConverter.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions); } {{/anyOf}} {{/composedSchemas}} {{/model.discriminator}} - WriteProperties(ref writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions); + WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions); writer.WriteEndObject(); {{/lambda.trimLineBreaks}} } @@ -370,11 +393,12 @@ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, JsonSerializerOptions jsonSerializerOptions) { {{#lambda.trimTrailingWithNewLine}} {{#lambda.trimLineBreaks}} {{#allVars}} + {{^isDiscriminator}} {{^isNullable}} {{#vendorExtensions.x-is-reference-type}} if ({{^required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet && {{/required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null) @@ -382,8 +406,18 @@ {{/vendorExtensions.x-is-reference-type}} {{/isNullable}} + {{/isDiscriminator}} {{/allVars}} {{#allVars}} + {{#isDiscriminator}} + {{^model.composedSchemas.anyOf}} + {{^model.composedSchemas.oneOf}} + writer.WriteString("{{baseName}}", {{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{/isEnum}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}.Value{{/required}}){{/isEnum}}{{/isNew}}); + + {{/model.composedSchemas.oneOf}} + {{/model.composedSchemas.anyOf}} + {{/isDiscriminator}} + {{^isDiscriminator}} {{#isString}} {{^isMap}} {{^isEnum}} @@ -579,6 +613,7 @@ {{/isString}} {{/isEnum}} {{/isUuid}} + {{/isDiscriminator}} {{/allVars}} {{/lambda.trimLineBreaks}} {{/lambda.trimTrailingWithNewLine}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache index 94a34cf51f83..909a68e354fb 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelBaseSignature.mustache @@ -1 +1 @@ -{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}} \ No newline at end of file +{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{parent}}{{/lambda.camelcase_sanitize_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{^isDiscriminator}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{{datatypeWithEnum}}}ToJsonValue{{/isInnerEnum}}{{^isInnerEnum}}{{{datatypeWithEnum}}}ValueConverter.ToJsonValue{{/isInnerEnum}}({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/isDiscriminator}}{{/allVars}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache index d16e13065f15..39aa11f82abe 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ModelSignature.mustache @@ -1 +1 @@ -{{#model.allVars}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}{{#defaultValue}} = {{^required}}default{{/required}}{{#required}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{.}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/required}}{{/defaultValue}}{{^defaultValue}}{{#lambda.first}}{{#isNullable}} = default {{/isNullable}}{{^required}} = default {{/required}}{{/lambda.first}}{{/defaultValue}} {{/model.allVars}} +{{#model.allVars}}{{^isDiscriminator}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}{{#defaultValue}} = {{^required}}default{{/required}}{{#required}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{.}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/required}}{{/defaultValue}}{{^defaultValue}}{{#lambda.first}}{{#isNullable}} = default {{/isNullable}}{{^required}} = default {{/required}}{{/lambda.first}}{{/defaultValue}} {{/isDiscriminator}}{{/model.allVars}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache index d5fe88663bb0..556d6f0e9d4a 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/modelGeneric.mustache @@ -13,7 +13,9 @@ /// {{/composedSchemas.anyOf}} {{#allVars}} + {{^isDiscriminator}} /// {{description}}{{^description}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}} + {{/isDiscriminator}} {{/allVars}} {{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{{dataType}}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}} {{#model.composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{baseType}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{parent}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}} { @@ -22,6 +24,7 @@ {{/composedSchemas.anyOf}} {{name}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{#allVars}} + {{^isDiscriminator}} {{^isInherited}} {{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{/isInherited}} @@ -30,6 +33,7 @@ {{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{/isNew}} {{/isInherited}} + {{/isDiscriminator}} {{/allVars}} OnCreated(); } @@ -44,7 +48,9 @@ /// {{/composedSchemas.anyOf}} {{#allVars}} + {{^isDiscriminator}} /// {{description}}{{^description}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}} + {{/isDiscriminator}} {{/allVars}} {{^composedSchemas.anyOf}} [JsonConstructor] @@ -55,6 +61,7 @@ {{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{/composedSchemas.anyOf}} {{#allVars}} + {{^isDiscriminator}} {{^isInherited}} {{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{/isInherited}} @@ -63,6 +70,7 @@ {{name}}{{^required}}Option{{/required}} = {{#lambda.escape_reserved_word}}{{#lambda.camel_case}}{{name}}{{/lambda.camel_case}}{{/lambda.escape_reserved_word}}; {{/isNew}} {{/isInherited}} + {{/isDiscriminator}} {{/allVars}} OnCreated(); } @@ -83,6 +91,7 @@ {{>modelInnerEnum}} {{/complexType}} {{/isEnum}} + {{^isDiscriminator}} {{#isEnum}} {{^required}} /// @@ -109,6 +118,7 @@ public {{#isNew}}new {{/isNew}}{{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{name}}Option; } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}} {{/isEnum}} + {{/isDiscriminator}} {{/vars}} {{#composedSchemas.anyOf}} {{^vendorExtensions.x-duplicated-data-type}} @@ -152,6 +162,20 @@ {{/vendorExtensions.x-duplicated-data-type}} {{/composedSchemas.oneOf}} {{#allVars}} + {{#isDiscriminator}} + {{^model.composedSchemas.anyOf}} + {{^model.composedSchemas.oneOf}} + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public {{#isNew}}new {{/isNew}}{{datatypeWithEnum}} {{name}} { get; } = {{^isNew}}"{{classname}}"{{/isNew}}{{#isNew}}{{^isEnum}}"{{classname}}"{{/isEnum}}{{#isEnum}}({{datatypeWithEnum}})Enum.Parse(typeof({{datatypeWithEnum}}), "{{classname}}"){{/isEnum}}{{/isNew}}; + + {{/model.composedSchemas.oneOf}} + {{/model.composedSchemas.anyOf}} + {{/isDiscriminator}} + {{^isDiscriminator}} {{^isEnum}} {{#isInherited}} {{#isNew}} @@ -204,6 +228,7 @@ {{/isInherited}} {{/isEnum}} + {{/isDiscriminator}} {{/allVars}} {{#isAdditionalPropertiesTrue}} {{^parentModel}} @@ -227,7 +252,9 @@ sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); {{/parent}} {{#vars}} + {{^isDiscriminator}} sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); + {{/isDiscriminator}} {{/vars}} {{#isAdditionalPropertiesTrue}} {{^parentModel}} diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 76ccb5126adf..07611aff320e 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -266,6 +266,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs index 4fdb779b1426..5c879e6f980c 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs @@ -37,9 +37,8 @@ public partial class Adult : Person, IValidatableObject /// children /// firstName /// lastName - /// type [JsonConstructor] - public Adult(Option?> children = default, Option firstName = default, Option lastName = default, Option type = default) : base(firstName, lastName, type) + public Adult(Option?> children = default, Option firstName = default, Option lastName = default) : base(firstName, lastName) { ChildrenOption = children; OnCreated(); @@ -60,6 +59,13 @@ public Adult(Option?> children = default, Option firstName [JsonPropertyName("children")] public List? Children { get { return this.ChildrenOption; } set { this.ChildrenOption = new(value); } } + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string Type { get; } = "Adult"; + /// /// Returns the string presentation of the object /// @@ -148,7 +154,7 @@ public override Adult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert if (type.IsSet && type.Value == null) throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult."); - return new Adult(children, firstName, lastName, type); + return new Adult(children, firstName, lastName); } /// @@ -162,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, adult, jsonSerializerOptions); + WriteProperties(writer, adult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -173,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -184,9 +190,6 @@ public void WriteProperties(ref Utf8JsonWriter writer, Adult adult, JsonSerializ if (adult.LastNameOption.IsSet && adult.LastName == null) throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult."); - if (adult.TypeOption.IsSet && adult.Type == null) - throw new ArgumentNullException(nameof(adult.Type), "Property is required for class Adult."); - if (adult.ChildrenOption.IsSet) { writer.WritePropertyName("children"); @@ -198,8 +201,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, Adult adult, JsonSerializ if (adult.LastNameOption.IsSet) writer.WriteString("lastName", adult.LastName); - if (adult.TypeOption.IsSet) - writer.WriteString("$_type", adult.Type); + writer.WriteString("$_type", adult.Type); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs index c82c4feb26ef..426cf4706eee 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs @@ -37,10 +37,9 @@ public partial class Child : Person, IValidatableObject /// age /// firstName /// lastName - /// type /// boosterSeat [JsonConstructor] - public Child(Option age = default, Option firstName = default, Option lastName = default, Option type = default, Option boosterSeat = default) : base(firstName, lastName, type) + public Child(Option age = default, Option firstName = default, Option lastName = default, Option boosterSeat = default) : base(firstName, lastName) { AgeOption = age; BoosterSeatOption = boosterSeat; @@ -62,6 +61,13 @@ public Child(Option age = default, Option firstName = default, Op [JsonPropertyName("age")] public int? Age { get { return this.AgeOption; } set { this.AgeOption = new(value); } } + /// + /// The discriminator + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public new string Type { get; } = "Child"; + /// /// Used to track the state of BoosterSeat /// @@ -172,7 +178,7 @@ public override Child Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert if (boosterSeat.IsSet && boosterSeat.Value == null) throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child."); - return new Child(age, firstName, lastName, type, boosterSeat); + return new Child(age, firstName, lastName, boosterSeat); } /// @@ -186,7 +192,7 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, child, jsonSerializerOptions); + WriteProperties(writer, child, jsonSerializerOptions); writer.WriteEndObject(); } @@ -197,7 +203,7 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -205,9 +211,6 @@ public void WriteProperties(ref Utf8JsonWriter writer, Child child, JsonSerializ if (child.LastNameOption.IsSet && child.LastName == null) throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child."); - if (child.TypeOption.IsSet && child.Type == null) - throw new ArgumentNullException(nameof(child.Type), "Property is required for class Child."); - if (child.AgeOption.IsSet) writer.WriteNumber("age", child.AgeOption.Value!.Value); @@ -217,8 +220,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, Child child, JsonSerializ if (child.LastNameOption.IsSet) writer.WriteString("lastName", child.LastName); - if (child.TypeOption.IsSet) - writer.WriteString("$_type", child.Type); + writer.WriteString("$_type", child.Type); if (child.BoosterSeatOption.IsSet) writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value); diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs index b05de7bd8269..7acde5f926c6 100644 --- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs +++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs @@ -36,13 +36,11 @@ public partial class Person : IValidatableObject /// /// firstName /// lastName - /// type [JsonConstructor] - public Person(Option firstName = default, Option lastName = default, Option type = default) + public Person(Option firstName = default, Option lastName = default) { FirstNameOption = firstName; LastNameOption = lastName; - TypeOption = type; OnCreated(); } @@ -75,17 +73,11 @@ public Person(Option firstName = default, Option lastName = de public string? LastName { get { return this.LastNameOption; } set { this.LastNameOption = new(value); } } /// - /// Used to track the state of Type + /// The discriminator /// [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(value); } } + public string Type { get; } = "Person"; /// /// Gets or Sets additional properties @@ -103,7 +95,6 @@ public override string ToString() sb.Append("class Person {\n"); sb.Append(" FirstName: ").Append(FirstName).Append("\n"); sb.Append(" LastName: ").Append(LastName).Append("\n"); - sb.Append(" Type: ").Append(Type).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -156,6 +147,14 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -195,7 +194,7 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (type.IsSet && type.Value == null) throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person."); - return new Person(firstName, lastName, type); + return new Person(firstName, lastName); } /// @@ -207,9 +206,19 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, person, jsonSerializerOptions); + WriteProperties(writer, person, jsonSerializerOptions); writer.WriteEndObject(); } @@ -220,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -228,17 +237,13 @@ public void WriteProperties(ref Utf8JsonWriter writer, Person person, JsonSerial if (person.LastNameOption.IsSet && person.LastName == null) throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person."); - if (person.TypeOption.IsSet && person.Type == null) - throw new ArgumentNullException(nameof(person.Type), "Property is required for class Person."); - if (person.FirstNameOption.IsSet) writer.WriteString("firstName", person.FirstName); if (person.LastNameOption.IsSet) writer.WriteString("lastName", person.LastName); - if (person.TypeOption.IsSet) - writer.WriteString("$_type", person.Type); + writer.WriteString("$_type", person.Type); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 57169a68de3b..906cd9937170 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -266,6 +266,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs index e933186d8e08..c887090b6ca7 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs index 102dc422c2e4..ad5d19ad12d5 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs index 053d067c836c..fde1dab02725 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -212,16 +212,16 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, fruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, fruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -232,7 +232,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs index fcb4e3b1152b..581159c00050 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -251,6 +251,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs index 96cf1c1e5eda..abd80a481805 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs index a2ec1b7eadfe..0425d7792236 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs index 8598723e3f38..415bc63ab438 100644 --- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs @@ -211,16 +211,16 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt if (fruit.AppleOption.IsSet && fruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(fruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, fruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, fruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, fruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -231,7 +231,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 26a81eb53307..1f8bfa7f6366 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -355,6 +355,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs index 2ed0cacfe1ee..b746b781c3e2 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Activity.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, activity, jsonSerializerOptions); + WriteProperties(writer, activity, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index e51af3a1a80d..3afdabfc6d58 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent { writer.WriteStartObject(); - WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions); + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 8aecec6328ed..b422890b171c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -318,7 +318,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi { writer.WriteStartObject(); - WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -329,7 +329,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs index 700f201cf894..aea749057480 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Animal.cs @@ -32,12 +32,10 @@ public partial class Animal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, Option color = default) + public Animal(Option color = default) { - ClassName = className; ColorOption = color; OnCreated(); } @@ -45,10 +43,11 @@ public Animal(string className, Option color = default) partial void OnCreated(); /// - /// Gets or Sets ClassName + /// The discriminator /// - [JsonPropertyName("className")] - public string ClassName { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; /// /// Used to track the state of Color @@ -77,7 +76,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); @@ -130,6 +128,14 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -166,7 +172,7 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); - return new Animal(className.Value, color); + return new Animal(color); } /// @@ -178,9 +184,19 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, animal, jsonSerializerOptions); + WriteProperties(writer, animal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -191,11 +207,8 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { - if (animal.ClassName == null) - throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); - if (animal.ColorOption.IsSet && animal.Color == null) throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs index 84fa6eef72ca..02c11a9a77ee 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -198,7 +198,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, apiResponse, jsonSerializerOptions); + WriteProperties(writer, apiResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -209,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs index 233ec205fd33..59e078d0a8dd 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Apple.cs @@ -227,7 +227,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -238,7 +238,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs index eccab20bd13d..9801b197763e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/AppleReq.cs @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, appleReq, jsonSerializerOptions); + WriteProperties(writer, appleReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 2935b372eee1..7decd736dd63 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 1e028acb226c..d9c4bbd05e49 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs index f0990197e1d7..0d5cf364c0bf 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -200,7 +200,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, arrayTest, jsonSerializerOptions); + WriteProperties(writer, arrayTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -211,7 +211,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs index 773f3d09bf95..5deb7b3cabb7 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Banana.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs index d8b91e33ae20..1ead980e60ac 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BananaReq.cs @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, bananaReq, jsonSerializerOptions); + WriteProperties(writer, bananaReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs index 53c20a25cd10..863cc82bc782 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/BasquePig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, basquePig, jsonSerializerOptions); + WriteProperties(writer, basquePig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs index fe9e72647b7d..5ee27d790d1e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Capitalization.cs @@ -267,7 +267,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, { writer.WriteStartObject(); - WriteProperties(ref writer, capitalization, jsonSerializerOptions); + WriteProperties(writer, capitalization, jsonSerializerOptions); writer.WriteEndObject(); } @@ -278,7 +278,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs index b60c6b69a4e3..33d826fa7ea9 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Cat.cs @@ -32,11 +32,10 @@ public partial class Cat : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") /// declawed [JsonConstructor] - public Cat(string className, Option color = default, Option declawed = default) : base(className, color) + public Cat(Option color = default, Option declawed = default) : base(color) { DeclawedOption = declawed; OnCreated(); @@ -44,6 +43,13 @@ public Cat(string className, Option color = default, Option decla 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 /// @@ -141,7 +147,7 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (declawed.IsSet && declawed.Value == null) throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); - return new Cat(className.Value, color, declawed); + return new Cat(color, declawed); } /// @@ -155,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, cat, jsonSerializerOptions); + WriteProperties(writer, cat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,11 +172,8 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { - if (cat.ClassName == null) - throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); - if (cat.ColorOption.IsSet && cat.Color == null) throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs index a880d914ef00..646d804623a3 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Category.cs @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, category, jsonSerializerOptions); + WriteProperties(writer, category, jsonSerializerOptions); writer.WriteEndObject(); } @@ -182,7 +182,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs index e45ece9c076f..4caedf25fce9 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ChildCat.cs @@ -32,12 +32,10 @@ public partial class ChildCat : ParentPet, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType /// name [JsonConstructor] - public ChildCat(ChildCatAllOfPetType petType, Option name = default) : base(ChildCatAllOfPetTypeValueConverter.ToJsonValue(petType)) + public ChildCat(Option name = default) : base() { - PetType = petType; NameOption = name; OnCreated(); } @@ -45,10 +43,11 @@ public ChildCat(ChildCatAllOfPetType petType, Option name = default) : b partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public new ChildCatAllOfPetType PetType { get; set; } + [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 @@ -72,7 +71,6 @@ 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(" PetType: ").Append(PetType).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -142,7 +140,7 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv if (name.IsSet && name.Value == null) throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat."); - return new ChildCat(petType.Value.Value, name); + return new ChildCat(name); } /// @@ -156,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, childCat, jsonSerializerOptions); + WriteProperties(writer, childCat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -167,13 +165,12 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + 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."); - var petTypeRawValue = ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCat.PetType); - writer.WriteString("pet_type", petTypeRawValue); + 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/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs index 31f98f66f508..3740f80f7c4f 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ClassModel.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, classModel, jsonSerializerOptions); + WriteProperties(writer, classModel, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 747b36ec65bd..1a42f967ca91 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu { writer.WriteStartObject(); - WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs index c28634e4e13e..9eb8b733358d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DanishPig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, danishPig, jsonSerializerOptions); + WriteProperties(writer, danishPig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 7d7789e3d8d4..4f3c74c26d9e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions); + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 2db62c460fc1..1ffcd1e09a87 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj { writer.WriteStartObject(); - WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions); + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs index cafd49dfda84..ee6d230b265a 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Dog.cs @@ -32,11 +32,10 @@ public partial class Dog : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// breed /// color (default to "red") [JsonConstructor] - public Dog(string className, Option breed = default, Option color = default) : base(className, color) + public Dog(Option breed = default, Option color = default) : base(color) { BreedOption = breed; OnCreated(); @@ -44,6 +43,13 @@ public Dog(string className, Option breed = default, Option colo 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 /// @@ -140,7 +146,7 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); - return new Dog(className.Value, breed, color); + return new Dog(breed, color); } /// @@ -154,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, dog, jsonSerializerOptions); + WriteProperties(writer, dog, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,11 +171,8 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - if (dog.ClassName == null) - throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); - if (dog.BreedOption.IsSet && dog.Breed == null) throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs index 29aaebc2075c..e5f2fb7e0258 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Drawing.cs @@ -218,7 +218,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, drawing, jsonSerializerOptions); + WriteProperties(writer, drawing, jsonSerializerOptions); writer.WriteEndObject(); } @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs index 3b102cc35c84..427a3cd1ffcb 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, enumArrays, jsonSerializerOptions); + WriteProperties(writer, enumArrays, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs index 830bec9aee23..47fbc6627724 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EnumTest.cs @@ -346,7 +346,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, enumTest, jsonSerializerOptions); + WriteProperties(writer, enumTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -357,7 +357,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { var enumStringRequiredRawValue = EnumTestEnumStringValueConverter.ToJsonValue(enumTest.EnumStringRequired); writer.WriteString("enum_string_required", enumStringRequiredRawValue); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index bbf4bf8f8e09..b84f89b531dc 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera { writer.WriteStartObject(); - WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions); + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs index dc4ffdfe56b8..49cc4b73830a 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/File.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, file, jsonSerializerOptions); + WriteProperties(writer, file, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 29f6d03ffd07..4c22995b6051 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema { writer.WriteStartObject(); - WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions); + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs index 21dba9216639..2b59206330a8 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Foo.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, foo, jsonSerializerOptions); + WriteProperties(writer, foo, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 21585e839d6f..42d40f715ec0 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe { writer.WriteStartObject(); - WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions); + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs index 24cc7c3f39b6..545fe1a83b67 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FormatTest.cs @@ -703,7 +703,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, formatTest, jsonSerializerOptions); + WriteProperties(writer, formatTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -714,7 +714,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs index 1c491c62a5ac..d39d2a29ad8a 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Fruit.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs index 03ef926c47d4..f5dd6d56278f 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/FruitReq.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, fruitReq, jsonSerializerOptions); + WriteProperties(writer, fruitReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs index b0ff469057d2..95772b5635b8 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GmFruit.cs @@ -203,16 +203,16 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, gmFruit, jsonSerializerOptions); + WriteProperties(writer, gmFruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 6b7d7ae8da68..86246ae54570 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -32,21 +32,20 @@ public partial class GrandparentAnimal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public GrandparentAnimal(string petType) + public GrandparentAnimal() { - PetType = petType; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public string PetType { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; /// /// Gets or Sets additional properties @@ -62,7 +61,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -113,6 +111,14 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t 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) @@ -143,7 +149,7 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); - return new GrandparentAnimal(petType.Value); + return new GrandparentAnimal(); } /// @@ -155,9 +161,19 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t /// 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(ref writer, grandparentAnimal, jsonSerializerOptions); + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -168,11 +184,8 @@ public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentA /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { - if (grandparentAnimal.PetType == null) - throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); - writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index a58bd7569681..88c5d4274eab 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -215,7 +215,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl { writer.WriteStartObject(); - WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions); + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 2c7412692513..0c916b0a208e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -148,7 +148,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR { writer.WriteStartObject(); - WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions); + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { if (healthCheckResult.NullableMessageOption.IsSet) if (healthCheckResult.NullableMessageOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 3f4aa3229c4e..384e48f3a155 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri { writer.WriteStartObject(); - WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions); + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -170,7 +170,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs index cbdf361981be..b4f4f31b7fd8 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/List.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, list, jsonSerializerOptions); + WriteProperties(writer, list, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 25c7ef39a736..9e1a7878ad50 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -174,7 +174,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri { writer.WriteStartObject(); - WriteProperties(ref writer, literalStringClass, jsonSerializerOptions); + WriteProperties(writer, literalStringClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -185,7 +185,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs index 05e439a9c3e6..1be5661d9936 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs @@ -33,11 +33,9 @@ public partial class Mammal : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Whale whale, string className) + public Mammal(Whale whale) { Whale = whale; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Mammal(Whale whale, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Zebra zebra, string className) + public Mammal(Zebra zebra) { Zebra = zebra; - ClassName = className; OnCreated(); } @@ -57,11 +53,9 @@ public Mammal(Zebra zebra, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Pig pig, string className) + public Mammal(Pig pig) { Pig = pig; - ClassName = className; OnCreated(); } @@ -82,12 +76,6 @@ public Mammal(Pig pig, string className) /// public Pig Pig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className.Value); + return new Mammal(pig); if (whale != null) - return new Mammal(whale, className.Value); + return new Mammal(whale); if (zebra != null) - return new Mammal(zebra, className.Value); + return new Mammal(zebra); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO if (mammal.Whale != null) { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); - whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } if (mammal.Zebra != null) { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); - zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } if (mammal.Pig != null) { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); - pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } - WriteProperties(ref writer, mammal, jsonSerializerOptions); + WriteProperties(writer, mammal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { - if (mammal.ClassName == null) - throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); - writer.WriteString("className", mammal.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs index f703c6769aa2..e99895fbeda2 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MapTest.cs @@ -224,7 +224,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, mapTest, jsonSerializerOptions); + WriteProperties(writer, mapTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -235,7 +235,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 5effb3c63c55..ae423667629f 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -236,7 +236,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -247,7 +247,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs index 6447826e7d8c..f503204de208 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Model200Response.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo { writer.WriteStartObject(); - WriteProperties(ref writer, model200Response, jsonSerializerOptions); + WriteProperties(writer, model200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs index 1c3b4cf30db3..cac0963a2014 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ModelClient.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, modelClient, jsonSerializerOptions); + WriteProperties(writer, modelClient, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs index 083a7233e15c..86bbf24f53a5 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Name.cs @@ -260,7 +260,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, name, jsonSerializerOptions); + WriteProperties(writer, name, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,7 +271,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index cd1516104e35..d10268f2927a 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R { writer.WriteStartObject(); - WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs index e5aa83541370..fcafbb947441 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableClass.cs @@ -395,7 +395,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, nullableClass, jsonSerializerOptions); + WriteProperties(writer, nullableClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs index e4ecd87be6a5..4b5f815656a8 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid { writer.WriteStartObject(); - WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions); + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { if (nullableGuidClass.UuidOption.IsSet) if (nullableGuidClass.UuidOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs index d66595994262..10061a2c228b 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs @@ -33,11 +33,9 @@ public partial class NullableShape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Triangle triangle, string shapeType) + public NullableShape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public NullableShape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Quadrilateral quadrilateral, string shapeType) + public NullableShape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public NullableShape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType.Value); + return new NullableShape(quadrilateral); if (triangle != null) - return new NullableShape(triangle, shapeType.Value); + return new NullableShape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J if (nullableShape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } if (nullableShape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, nullableShape, jsonSerializerOptions); + WriteProperties(writer, nullableShape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { - if (nullableShape.ShapeType == null) - throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); - writer.WriteString("shapeType", nullableShape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs index b54928bcca58..15c9e5cbfcbb 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, numberOnly, jsonSerializerOptions); + WriteProperties(writer, numberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + 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/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 8dc4e4d1b9e2..b25d9e5fd872 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj { writer.WriteStartObject(); - WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions); + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); writer.WriteEndObject(); } @@ -237,7 +237,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs index 258453564b0b..0f4f13f311b0 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OneOfString.cs @@ -138,7 +138,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, oneOfString, jsonSerializerOptions); + WriteProperties(writer, oneOfString, jsonSerializerOptions); writer.WriteEndObject(); } @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs index db011f4a4c61..a0d820562b40 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Order.cs @@ -279,7 +279,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, order, jsonSerializerOptions); + WriteProperties(writer, order, jsonSerializerOptions); writer.WriteEndObject(); } @@ -290,7 +290,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { if (order.CompleteOption.IsSet) writer.WriteBoolean("complete", order.CompleteOption.Value.Value); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs index c4592b634a36..daa467e228b5 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -199,7 +199,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, { writer.WriteStartObject(); - WriteProperties(ref writer, outerComposite, jsonSerializerOptions); + WriteProperties(writer, outerComposite, jsonSerializerOptions); writer.WriteEndObject(); } @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs index c451e1a8991b..5d1cab769fa8 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ParentPet.cs @@ -32,15 +32,21 @@ public partial class ParentPet : GrandparentAnimal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public ParentPet(string petType) : base(petType) + 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 /// @@ -79,6 +85,11 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon 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) @@ -109,7 +120,7 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); - return new ParentPet(petType.Value); + return new ParentPet(); } /// @@ -121,9 +132,14 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon /// public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + writer.WriteStartObject(); - WriteProperties(ref writer, parentPet, jsonSerializerOptions); + WriteProperties(writer, parentPet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -134,11 +150,8 @@ public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { - if (parentPet.PetType == null) - throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); - writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs index c8d55edaca67..43fb8d49cc24 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pet.cs @@ -265,7 +265,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, pet, jsonSerializerOptions); + WriteProperties(writer, pet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -276,7 +276,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs index d3bbeb8ff326..19e395f1de47 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs @@ -33,11 +33,9 @@ public partial class Pig : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Pig(BasquePig basquePig, string className) + public Pig(BasquePig basquePig) { BasquePig = basquePig; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Pig(BasquePig basquePig, string className) /// Initializes a new instance of the class. /// /// - /// className - public Pig(DanishPig danishPig, string className) + public Pig(DanishPig danishPig) { DanishPig = danishPig; - ClassName = className; OnCreated(); } @@ -65,12 +61,6 @@ public Pig(DanishPig danishPig, string className) /// public DanishPig DanishPig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className.Value); + return new Pig(basquePig); if (danishPig != null) - return new Pig(danishPig, className.Value); + return new Pig(danishPig); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions if (pig.BasquePig != null) { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); - basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } if (pig.DanishPig != null) { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); - danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } - WriteProperties(ref writer, pig, jsonSerializerOptions); + WriteProperties(writer, pig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { - if (pig.ClassName == null) - throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); - writer.WriteString("className", pig.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 0c176589d063..30edd0b77d2d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -220,7 +220,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi { writer.WriteStartObject(); - WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions); + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); writer.WriteEndObject(); } @@ -231,7 +231,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs index f3ef21718ae4..3d333d7958fb 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -33,11 +33,9 @@ public partial class Quadrilateral : IValidatableObject /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType) + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { SimpleQuadrilateral = simpleQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -45,11 +43,9 @@ public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilater /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType) + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { ComplexQuadrilateral = complexQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -65,12 +61,6 @@ public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilat /// public ComplexQuadrilateral ComplexQuadrilateral { get; set; } - /// - /// Gets or Sets QuadrilateralType - /// - [JsonPropertyName("quadrilateralType")] - public string QuadrilateralType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(complexQuadrilateral); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(simpleQuadrilateral); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J if (quadrilateral.SimpleQuadrilateral != null) { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); - simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } if (quadrilateral.ComplexQuadrilateral != null) { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); - complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, quadrilateral, jsonSerializerOptions); + WriteProperties(writer, quadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { - if (quadrilateral.QuadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); - writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 75b7e516cfca..610005a05408 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril { writer.WriteStartObject(); - WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions); + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 46c7177ca57e..5ef0b0448074 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J { writer.WriteStartObject(); - WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions); + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs index bf168ddaecde..56d57fa30c0c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -1086,7 +1086,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + WriteProperties(writer, requiredClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -1097,7 +1097,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs index 5804b46eff20..30c6b4d7fe9b 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Return.cs @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ { writer.WriteStartObject(); - WriteProperties(ref writer, varReturn, jsonSerializerOptions); + WriteProperties(writer, varReturn, jsonSerializerOptions); writer.WriteEndObject(); } @@ -221,7 +221,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 306c5b8f7278..14e2d9ee12fa 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index 763295f24971..1e19e81e55c5 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 52a8e0d69c60..47081ede38ef 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl { writer.WriteStartObject(); - WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions); + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs index ffd95a8fdff1..d4883a363a21 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs @@ -33,11 +33,9 @@ public partial class Shape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Triangle triangle, string shapeType) + public Shape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public Shape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Quadrilateral quadrilateral, string shapeType) + public Shape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public Shape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType.Value); + return new Shape(quadrilateral); if (triangle != null) - return new Shape(triangle, shapeType.Value); + return new Shape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt if (shape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } if (shape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shape, jsonSerializerOptions); + WriteProperties(writer, shape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { - if (shape.ShapeType == null) - throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); - writer.WriteString("shapeType", shape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs index 5bd364cc6a41..3027d9142baf 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, { writer.WriteStartObject(); - WriteProperties(ref writer, shapeInterface, jsonSerializerOptions); + WriteProperties(writer, shapeInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs index d60f396c70da..2d9fb2cbb334 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -33,11 +33,9 @@ public partial class ShapeOrNull : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Triangle triangle, string shapeType) + public ShapeOrNull(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public ShapeOrNull(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) + public ShapeOrNull(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType.Value); + return new ShapeOrNull(quadrilateral); if (triangle != null) - return new ShapeOrNull(triangle, shapeType.Value); + return new ShapeOrNull(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS if (shapeOrNull.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } if (shapeOrNull.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions); + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { - if (shapeOrNull.ShapeType == null) - throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); - writer.WriteString("shapeType", shapeOrNull.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index a00a87e2efa5..3fa8bdc19177 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad { writer.WriteStartObject(); - WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs index e90c6487364f..0cc19a946de1 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN { writer.WriteStartObject(); - WriteProperties(ref writer, specialModelName, jsonSerializerOptions); + WriteProperties(writer, specialModelName, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs index 84f19a2c8988..5c64df495c19 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Tag.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, tag, jsonSerializerOptions); + WriteProperties(writer, tag, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index 73886a2eca06..c5e4293dca4e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 599b515add99..798a4b835c90 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 1e3b57bfe36a..e6590dd351db 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs index 737124e080b3..d31d2948c652 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs @@ -33,11 +33,9 @@ public partial class Triangle : IValidatableObject /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) + public Triangle(EquilateralTriangle equilateralTriangle) { EquilateralTriangle = equilateralTriangle; - TriangleType = triangleType; OnCreated(); } @@ -45,11 +43,9 @@ public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) + public Triangle(IsoscelesTriangle isoscelesTriangle) { IsoscelesTriangle = isoscelesTriangle; - TriangleType = triangleType; OnCreated(); } @@ -57,11 +53,9 @@ public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) + public Triangle(ScaleneTriangle scaleneTriangle) { ScaleneTriangle = scaleneTriangle; - TriangleType = triangleType; OnCreated(); } @@ -82,12 +76,6 @@ public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) /// public ScaleneTriangle ScaleneTriangle { get; set; } - /// - /// Gets or Sets TriangleType - /// - [JsonPropertyName("triangleType")] - public string TriangleType { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType.Value); + return new Triangle(equilateralTriangle); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType.Value); + return new Triangle(isoscelesTriangle); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType.Value); + return new Triangle(scaleneTriangle); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali if (triangle.EquilateralTriangle != null) { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); - equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } if (triangle.IsoscelesTriangle != null) { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); - isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } if (triangle.ScaleneTriangle != null) { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); - scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } - WriteProperties(ref writer, triangle, jsonSerializerOptions); + WriteProperties(writer, triangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { - if (triangle.TriangleType == null) - throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); - writer.WriteString("triangleType", triangle.TriangleType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs index 270c598de618..aa6d31b91909 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte { writer.WriteStartObject(); - WriteProperties(ref writer, triangleInterface, jsonSerializerOptions); + WriteProperties(writer, triangleInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs index 22330c4f5a8f..ea5842d39f41 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/User.cs @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, user, jsonSerializerOptions); + WriteProperties(writer, user, jsonSerializerOptions); writer.WriteEndObject(); } @@ -417,7 +417,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs index b130c0fbf886..258c1713bcc2 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Whale.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, whale, jsonSerializerOptions); + WriteProperties(writer, whale, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs index 0fe5dea1ff16..5479d7346cdf 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Zebra.cs @@ -172,7 +172,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, zebra, jsonSerializerOptions); + WriteProperties(writer, zebra, jsonSerializerOptions); writer.WriteEndObject(); } @@ -183,7 +183,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 12d12b9fddbf..a8d79997472e 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn { writer.WriteStartObject(); - WriteProperties(ref writer, zeroBasedEnumClass, jsonSerializerOptions); + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { if (zeroBasedEnumClass.ZeroBasedEnumOption.IsSet) { diff --git a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs index 20513bc2f8f6..eba2904f0bd0 100644 --- a/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs +++ b/samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs @@ -47,101 +47,147 @@ public SerializationTests() [TestMethod] public void Apple() { - Apple apple = new("#000000", "cultivar", "origin"); - string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions); - Apple? apple2 = JsonSerializer.Deserialize(appleJson, _jsonSerializerOptions); - Assert.IsTrue(apple2 != null && apple.Cultivar != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin != null && apple.Origin.Equals(apple2.Origin)); + string expected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin"}"""; + Apple? apple = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(apple, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void Pig() { - BasquePig basquePig = new("BasquePig"); - Pig pig = new(basquePig, "BasquePig"); - string pigJson = JsonSerializer.Serialize(pig, _jsonSerializerOptions); - Pig? pig2 = JsonSerializer.Deserialize(pigJson, _jsonSerializerOptions); - Assert.IsTrue( - pig.DanishPig == null && - pig.BasquePig != null && - pig2 != null && - pig2.BasquePig != null && - pig2.DanishPig == null && - pig2.BasquePig.ClassName.Equals(pig.BasquePig.ClassName)); + string expected = """{"className":"BasquePig"}"""; + Pig? pig = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(pig, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void DanishPig() { - DanishPig danishPig = new("danishPig"); - string danishPigJson = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions); - DanishPig? danishPig2 = JsonSerializer.Deserialize(danishPigJson, _jsonSerializerOptions); - Assert.IsTrue(danishPig2 != null && danishPig.ClassName.Equals(danishPig2.ClassName)); + string expected = """{"className":"DanishPig"}"""; + DanishPig? danishPig = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void GmFruit() { - Apple apple = new("#000000", "cultivar", "origin"); - Banana banana = new(10); - GmFruit gmFruit = new(apple, banana, "yellow"); - string gmFruitJson = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions); - GmFruit? gmFruit2 = JsonSerializer.Deserialize(gmFruitJson, _jsonSerializerOptions); - Assert.IsTrue( - gmFruit.Apple != null && - gmFruit.Banana != null && - gmFruit2 != null && - gmFruit2.Apple != null && - gmFruit2.Banana != null && - gmFruit2.Apple.Cultivar != null && - gmFruit2.Apple.Cultivar.Equals(gmFruit.Apple.Cultivar) && - gmFruit2.Apple.Origin != null && - gmFruit2.Apple.Origin.Equals(gmFruit.Apple.Origin) && - gmFruit2.Banana.LengthCm.Equals(gmFruit.Banana.LengthCm)); - - // TODO: assert the properties from Banana and GmFruit are in additionalProperties + string expected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin","lengthCm":10}"""; + GmFruit? gmFruit = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); + + Banana? banana = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string bananaActual = JsonSerializer.Serialize(banana); + string bananaExpected = """{"lengthCm":10}"""; + Assert.AreEqual(bananaExpected, bananaActual); + + Apple? apple = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string appleActual = JsonSerializer.Serialize(apple); + string appleExpected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin"}"""; + Assert.AreEqual(appleExpected, appleActual); } [TestMethod] public void EquilateralTriangle() { - EquilateralTriangle equilateralTriangle = new("triangle", "equilateral"); - string equilateralTriangleJson = JsonSerializer.Serialize(equilateralTriangle, _jsonSerializerOptions); - EquilateralTriangle? equilateralTriangle2 = JsonSerializer.Deserialize(equilateralTriangleJson, _jsonSerializerOptions); - Assert.IsTrue(equilateralTriangle2 != null && equilateralTriangle.TriangleType.Equals(equilateralTriangle2.TriangleType) && equilateralTriangle.ShapeType.Equals(equilateralTriangle2.ShapeType)); + string expected = """{"shapeType":"triangle","triangleType":"equilateral"}"""; + EquilateralTriangle? triangle = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(triangle, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void Quadrilateral() { - ComplexQuadrilateral complexQuadrilateral = new("ComplexQuadrilateral", "shapeType"); - Quadrilateral quadrilateral = new(complexQuadrilateral, "ComplexQuadrilateral"); - string quadrilateralJson = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions); - Quadrilateral? quadrilateral2 = JsonSerializer.Deserialize(quadrilateralJson, _jsonSerializerOptions); - Assert.IsTrue( - quadrilateral.ComplexQuadrilateral != null && - quadrilateral2 != null && - quadrilateral2.SimpleQuadrilateral == null && - quadrilateral2.ComplexQuadrilateral != null && - quadrilateral2.ComplexQuadrilateral.QuadrilateralType.Equals(quadrilateral.ComplexQuadrilateral.QuadrilateralType) && - quadrilateral2.ComplexQuadrilateral.ShapeType.Equals(quadrilateral.ComplexQuadrilateral.ShapeType)); + string expected = """{"quadrilateralType":"SimpleQuadrilateral","shapeType":"some quadralateral"}"""; + Quadrilateral? quadrilateral = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); + } + + [TestMethod] + public void SimpleQuadrilateral() + { + string expected = """{"quadrilateralType":"SimpleQuadrilateral","shapeType":"some quadralateral"}"""; + SimpleQuadrilateral? simpleQuadrilateral = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string simpleQuadrilateralActual = JsonSerializer.Serialize(simpleQuadrilateral, _jsonSerializerOptions); + Assert.AreEqual(expected, simpleQuadrilateralActual); + } + + [TestMethod] + public void ComplexQuadrilateral() + { + string complexQuadrilateralExpected = """{"quadrilateralType":"ComplexQuadrilateral","shapeType":"some quadralateral"}"""; + ComplexQuadrilateral? complexQuadrilateral = JsonSerializer.Deserialize(complexQuadrilateralExpected, _jsonSerializerOptions); + string complexQuadrilateralActual = JsonSerializer.Serialize(complexQuadrilateral, _jsonSerializerOptions); + Assert.AreEqual(complexQuadrilateralExpected, complexQuadrilateralActual); } [TestMethod] public void ChildCat() { - ChildCat childCat = new("some name", Org.OpenAPITools.Model.ChildCat.PetTypeEnum.ChildCat); - string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); - ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, _jsonSerializerOptions); - Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name != null && childCat.Name.Equals(childCat2.Name)); + string childCatExpected = """{"name":"foo","pet_type":"ChildCat"}"""; + ChildCat? childCat = JsonSerializer.Deserialize(childCatExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); + Assert.AreEqual(childCatExpected, childCatActual); } [TestMethod] public void Cat() { - Cat cat = new("cat", "black", false); // TODO: where is the address property? - string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions); - Cat? cat2 = JsonSerializer.Deserialize(catJson, _jsonSerializerOptions); - Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color != null && cat.Color.Equals(cat2.Color)); // TODO: add the address property + string catExpected = """{"className":"Cat","color":"black","declawed":true}"""; + Cat? cat = JsonSerializer.Deserialize(catExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(cat, _jsonSerializerOptions); + Assert.AreEqual(catExpected, childCatActual); + } + + [TestMethod] + public void Dog() + { + string dogExpected = """{"className":"Dog","breed":"Maltese"}"""; + Dog? dog = JsonSerializer.Deserialize(dogExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(dog, _jsonSerializerOptions); + Assert.AreEqual(dogExpected, childCatActual); + } + + [TestMethod] + public void Whale() + { + string expected = """{"className":"whale","hasBaleen":true,"hasTeeth":true}"""; + Whale? whale = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(whale, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void Mammal() + { + string expected = """{"className":"whale","hasBaleen":true,"hasTeeth":true}"""; + Mammal? mammal = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(mammal, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void ParentPet() + { + string expected = """{"pet_type":"ParentPet"}"""; + ParentPet? parentPet = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(parentPet, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void Animal() + { + string expected = """{"className":"Dog","breed":"maltese","color":"white"}"""; + Animal? animal = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + Assert.IsInstanceOfType(animal); + string result = JsonSerializer.Serialize(animal, _jsonSerializerOptions); + Assert.AreEqual(expected, result); } } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs b/samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs index f42b1a20a843..8a6a5fb3a906 100644 --- a/samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs +++ b/samples/client/petstore/csharp/generichost/net8/ManualSourceGenerationTests/ManualTests.Latest.UseSourceGeneration/UnitTest1.cs @@ -48,114 +48,150 @@ public SerializationTests() _jsonSerializerOptions = _host.Services.GetRequiredService().Options; } - [TestMethod] - public void Category() - { - Category category = new(1, "test"); - string categoryJson = JsonSerializer.Serialize(category, _jsonSerializerOptions); - Category? category2 = JsonSerializer.Deserialize(categoryJson, _jsonSerializerOptions); - Assert.AreEqual(category.Id, category2?.Id); - Assert.AreEqual(category.Name, category2?.Name); - } - [TestMethod] public void Apple() { - Apple apple = new("#000000", "cultivar", "origin"); - string appleJson = JsonSerializer.Serialize(apple, _jsonSerializerOptions); - Apple? apple2 = JsonSerializer.Deserialize(appleJson, _jsonSerializerOptions); - Assert.IsTrue(apple2 != null && apple.Cultivar != null && apple.Cultivar.Equals(apple2.Cultivar) && apple.Origin != null && apple.Origin.Equals(apple2.Origin)); + string expected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin"}"""; + Apple? apple = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(apple, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void Pig() { - BasquePig basquePig = new("BasquePig"); - Pig pig = new(basquePig, "BasquePig"); - string pigJson = JsonSerializer.Serialize(pig, _jsonSerializerOptions); - Pig? pig2 = JsonSerializer.Deserialize(pigJson, _jsonSerializerOptions); - Assert.IsTrue( - pig.DanishPig == null && - pig.BasquePig != null && - pig2 != null && - pig2.BasquePig != null && - pig2.DanishPig == null && - pig2.BasquePig.ClassName.Equals(pig.BasquePig.ClassName)); + string expected = """{"className":"BasquePig"}"""; + Pig? pig = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(pig, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void DanishPig() { - DanishPig danishPig = new("danishPig"); - string danishPigJson = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions); - DanishPig? danishPig2 = JsonSerializer.Deserialize(danishPigJson, _jsonSerializerOptions); - Assert.IsTrue(danishPig2 != null && danishPig.ClassName.Equals(danishPig2.ClassName)); + string expected = """{"className":"DanishPig"}"""; + DanishPig? danishPig = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(danishPig, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void GmFruit() { - Apple apple = new("#000000", "cultivar", "origin"); - Banana banana = new(10); - GmFruit gmFruit = new(apple, banana, "yellow"); - string gmFruitJson = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions); - GmFruit? gmFruit2 = JsonSerializer.Deserialize(gmFruitJson, _jsonSerializerOptions); - Assert.IsTrue( - gmFruit.Apple != null && - gmFruit.Banana != null && - gmFruit2 != null && - gmFruit2.Apple != null && - gmFruit2.Banana != null && - gmFruit2.Apple.Cultivar != null && - gmFruit2.Apple.Cultivar.Equals(gmFruit.Apple.Cultivar) && - gmFruit2.Apple.Origin != null && - gmFruit2.Apple.Origin.Equals(gmFruit.Apple.Origin) && - gmFruit2.Banana.LengthCm.Equals(gmFruit.Banana.LengthCm)); - - // TODO: assert the properties from Banana and GmFruit are in additionalProperties + string expected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin","lengthCm":10}"""; + GmFruit? gmFruit = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(gmFruit, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); + + Banana? banana = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string bananaActual = JsonSerializer.Serialize(banana); + string bananaExpected = """{"lengthCm":10}"""; + Assert.AreEqual(bananaExpected, bananaActual); + + Apple? apple = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string appleActual = JsonSerializer.Serialize(apple); + string appleExpected = """{"color_code":"#000000","cultivar":"cultivar","origin":"origin"}"""; + Assert.AreEqual(appleExpected, appleActual); } [TestMethod] public void EquilateralTriangle() { - EquilateralTriangle equilateralTriangle = new("triangle", "equilateral"); - string equilateralTriangleJson = JsonSerializer.Serialize(equilateralTriangle, _jsonSerializerOptions); - EquilateralTriangle? equilateralTriangle2 = JsonSerializer.Deserialize(equilateralTriangleJson, _jsonSerializerOptions); - Assert.IsTrue(equilateralTriangle2 != null && equilateralTriangle.TriangleType.Equals(equilateralTriangle2.TriangleType) && equilateralTriangle.ShapeType.Equals(equilateralTriangle2.ShapeType)); + string expected = """{"shapeType":"triangle","triangleType":"equilateral"}"""; + EquilateralTriangle? triangle = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(triangle, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); } [TestMethod] public void Quadrilateral() { - ComplexQuadrilateral complexQuadrilateral = new("ComplexQuadrilateral", "shapeType"); - Quadrilateral quadrilateral = new(complexQuadrilateral, "ComplexQuadrilateral"); - string quadrilateralJson = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions); - Quadrilateral? quadrilateral2 = JsonSerializer.Deserialize(quadrilateralJson, _jsonSerializerOptions); - Assert.IsTrue( - quadrilateral.ComplexQuadrilateral != null && - quadrilateral2 != null && - quadrilateral2.SimpleQuadrilateral == null && - quadrilateral2.ComplexQuadrilateral != null && - quadrilateral2.ComplexQuadrilateral.QuadrilateralType.Equals(quadrilateral.ComplexQuadrilateral.QuadrilateralType) && - quadrilateral2.ComplexQuadrilateral.ShapeType.Equals(quadrilateral.ComplexQuadrilateral.ShapeType)); + string expected = """{"quadrilateralType":"SimpleQuadrilateral","shapeType":"some quadralateral"}"""; + Quadrilateral? quadrilateral = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string actual = JsonSerializer.Serialize(quadrilateral, _jsonSerializerOptions); + Assert.AreEqual(expected, actual); + } + + [TestMethod] + public void SimpleQuadrilateral() + { + string expected = """{"quadrilateralType":"SimpleQuadrilateral","shapeType":"some quadralateral"}"""; + SimpleQuadrilateral? simpleQuadrilateral = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string simpleQuadrilateralActual = JsonSerializer.Serialize(simpleQuadrilateral, _jsonSerializerOptions); + Assert.AreEqual(expected, simpleQuadrilateralActual); } [TestMethod] - public void ChildCatTest() + public void ComplexQuadrilateral() { - ChildCat childCat = new("some name", ChildCat.PetTypeEnum.ChildCat); - string childCatJson = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); - ChildCat? childCat2 = JsonSerializer.Deserialize(childCatJson, _jsonSerializerOptions); - Assert.IsTrue(childCat2 != null && childCat.PetType.Equals(childCat2.PetType) && childCat.Name != null && childCat.Name.Equals(childCat2.Name)); + string complexQuadrilateralExpected = """{"quadrilateralType":"ComplexQuadrilateral","shapeType":"some quadralateral"}"""; + ComplexQuadrilateral? complexQuadrilateral = JsonSerializer.Deserialize(complexQuadrilateralExpected, _jsonSerializerOptions); + string complexQuadrilateralActual = JsonSerializer.Serialize(complexQuadrilateral, _jsonSerializerOptions); + Assert.AreEqual(complexQuadrilateralExpected, complexQuadrilateralActual); + } + + [TestMethod] + public void ChildCat() + { + string childCatExpected = """{"name":"foo","pet_type":"ChildCat"}"""; + ChildCat? childCat = JsonSerializer.Deserialize(childCatExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(childCat, _jsonSerializerOptions); + Assert.AreEqual(childCatExpected, childCatActual); } [TestMethod] public void Cat() { - Cat cat = new("cat", "black", false); // TODO: where is the address property? - string catJson = JsonSerializer.Serialize(cat, _jsonSerializerOptions); - Cat? cat2 = JsonSerializer.Deserialize(catJson, _jsonSerializerOptions); - Assert.IsTrue(cat2 != null && cat.Declawed.Equals(cat2.Declawed) && cat.ClassName.Equals(cat2.ClassName) && cat.Color != null && cat.Color.Equals(cat2.Color)); // TODO: add the address property + string catExpected = """{"className":"Cat","color":"black","declawed":true}"""; + Cat? cat = JsonSerializer.Deserialize(catExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(cat, _jsonSerializerOptions); + Assert.AreEqual(catExpected, childCatActual); + } + + [TestMethod] + public void Dog() + { + string dogExpected = """{"className":"Dog","breed":"Maltese"}"""; + Dog? dog = JsonSerializer.Deserialize(dogExpected, _jsonSerializerOptions); + string childCatActual = JsonSerializer.Serialize(dog, _jsonSerializerOptions); + Assert.AreEqual(dogExpected, childCatActual); + } + + [TestMethod] + public void Whale() + { + string expected = """{"className":"whale","hasBaleen":true,"hasTeeth":true}"""; + Whale? whale = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(whale, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void Mammal() + { + string expected = """{"className":"whale","hasBaleen":true,"hasTeeth":true}"""; + Mammal? mammal = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(mammal, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void ParentPet() + { + string expected = """{"pet_type":"ParentPet"}"""; + ParentPet? parentPet = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + string result = JsonSerializer.Serialize(parentPet, _jsonSerializerOptions); + Assert.AreEqual(expected, result); + } + + [TestMethod] + public void Animal() + { + string expected = """{"className":"Dog","breed":"maltese","color":"white"}"""; + Animal? animal = JsonSerializer.Deserialize(expected, _jsonSerializerOptions); + Assert.IsInstanceOfType(animal); + string result = JsonSerializer.Serialize(animal, _jsonSerializerOptions); + Assert.AreEqual(expected, result); } } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index 7c68fd649ffd..6a08eb32a3a7 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -361,6 +361,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs index 4912b6b209de..4ad0fb2c59a1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, activity, jsonSerializerOptions); + WriteProperties(writer, activity, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index f0ae7cbe7453..61ce42cec0f1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent { writer.WriteStartObject(); - WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions); + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 9a1e70894223..7e193b97f89f 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -320,7 +320,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi { writer.WriteStartObject(); - WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -331,7 +331,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs index 2a09079e539a..b6321f8a5fdf 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs @@ -34,12 +34,10 @@ public partial class Animal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, Option color = default) + public Animal(Option color = default) { - ClassName = className; ColorOption = color; OnCreated(); } @@ -47,10 +45,11 @@ public Animal(string className, Option color = default) partial void OnCreated(); /// - /// Gets or Sets ClassName + /// The discriminator /// - [JsonPropertyName("className")] - public string ClassName { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; /// /// Used to track the state of Color @@ -79,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); @@ -132,6 +130,14 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -168,7 +174,7 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); - return new Animal(className.Value!, color); + return new Animal(color); } /// @@ -180,9 +186,19 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, animal, jsonSerializerOptions); + WriteProperties(writer, animal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -193,11 +209,8 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { - if (animal.ClassName == null) - throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); - if (animal.ColorOption.IsSet && animal.Color == null) throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs index 1b32fc13a9ae..6224f2e1d3bd 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -200,7 +200,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, apiResponse, jsonSerializerOptions); + WriteProperties(writer, apiResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -211,7 +211,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs index da8939681a97..407c1858d9a1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,7 +240,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs index e58d2fdbbff9..422ed7a6308a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, appleReq, jsonSerializerOptions); + WriteProperties(writer, appleReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index afefccd4f4d1..cf54e27c98e1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index ebd297aee9d0..f8311fd47dac 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs index 2a03034765c8..10b89278cf4c 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -202,7 +202,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, arrayTest, jsonSerializerOptions); + WriteProperties(writer, arrayTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -213,7 +213,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs index cc7df0f17db0..1b9d4ad4b6d9 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs index 5c40df412a44..48f8d06506d4 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs @@ -167,7 +167,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, bananaReq, jsonSerializerOptions); + WriteProperties(writer, bananaReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs index 6388a29478f7..f523f75bffc5 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BasquePig.cs @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, basquePig, jsonSerializerOptions); + WriteProperties(writer, basquePig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs index ed19ba8d748e..0209e0ec34fe 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs @@ -269,7 +269,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, { writer.WriteStartObject(); - WriteProperties(ref writer, capitalization, jsonSerializerOptions); + WriteProperties(writer, capitalization, jsonSerializerOptions); writer.WriteEndObject(); } @@ -280,7 +280,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs index 4524364277c9..0a184e3a55e5 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs @@ -34,11 +34,10 @@ public partial class Cat : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") /// declawed [JsonConstructor] - public Cat(string className, Option color = default, Option declawed = default) : base(className, color) + public Cat(Option color = default, Option declawed = default) : base(color) { DeclawedOption = declawed; OnCreated(); @@ -46,6 +45,13 @@ public Cat(string className, Option color = default, Option decl 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 /// @@ -143,7 +149,7 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (declawed.IsSet && declawed.Value == null) throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); - return new Cat(className.Value!, color, declawed); + return new Cat(color, declawed); } /// @@ -157,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, cat, jsonSerializerOptions); + WriteProperties(writer, cat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -168,11 +174,8 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { - if (cat.ClassName == null) - throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); - if (cat.ColorOption.IsSet && cat.Color == null) throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs index 5f73a309fb2e..4e71363b8e6f 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs @@ -173,7 +173,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, category, jsonSerializerOptions); + WriteProperties(writer, category, jsonSerializerOptions); writer.WriteEndObject(); } @@ -184,7 +184,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs index fdcd705495b4..0c88f352be55 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs @@ -35,12 +35,10 @@ public partial class ChildCat : ParentPet, IValidatableObject /// Initializes a new instance of the class. /// /// name - /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default) : base() { NameOption = name; - PetType = petType; OnCreated(); } @@ -98,12 +96,6 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets PetType - /// - [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } - /// /// Used to track the state of Name /// @@ -117,6 +109,13 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) [JsonPropertyName("name")] public string? Name { get { return this.NameOption; } set { this.NameOption = new(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 /// @@ -127,7 +126,6 @@ public override string ToString() sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -196,7 +194,7 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value!.Value!); + return new ChildCat(name); } /// @@ -210,7 +208,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, childCat, jsonSerializerOptions); + WriteProperties(writer, childCat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -221,7 +219,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -229,8 +227,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSe if (childCat.NameOption.IsSet) writer.WriteString("name", childCat.Name); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); - writer.WriteString("pet_type", petTypeRawValue); + writer.WriteString("pet_type", ChildCat.PetTypeEnumToJsonValue(childCat.PetType)); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs index 74c96842c0ae..41acdb363b35 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, classModel, jsonSerializerOptions); + WriteProperties(writer, classModel, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 6e9034b20b2a..629d2072a7ca 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu { writer.WriteStartObject(); - WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs index cb41bcddcd6c..a3c590d56ce8 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DanishPig.cs @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, danishPig, jsonSerializerOptions); + WriteProperties(writer, danishPig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 951238cee27c..f28b51344dea 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions); + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 01fbd05864c0..33b840488f43 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj { writer.WriteStartObject(); - WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions); + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs index 4367b8d84be4..82c15b68b724 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs @@ -34,11 +34,10 @@ public partial class Dog : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// breed /// color (default to "red") [JsonConstructor] - public Dog(string className, Option breed = default, Option color = default) : base(className, color) + public Dog(Option breed = default, Option color = default) : base(color) { BreedOption = breed; OnCreated(); @@ -46,6 +45,13 @@ public Dog(string className, Option breed = default, Option co 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 /// @@ -142,7 +148,7 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); - return new Dog(className.Value!, breed, color); + return new Dog(breed, color); } /// @@ -156,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, dog, jsonSerializerOptions); + WriteProperties(writer, dog, jsonSerializerOptions); writer.WriteEndObject(); } @@ -167,11 +173,8 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - if (dog.ClassName == null) - throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); - if (dog.BreedOption.IsSet && dog.Breed == null) throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs index e388e5429584..768e72260b5e 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs @@ -220,7 +220,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, drawing, jsonSerializerOptions); + WriteProperties(writer, drawing, jsonSerializerOptions); writer.WriteEndObject(); } @@ -231,7 +231,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs index 4b4caf558498..f5dd6f17edfd 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -311,7 +311,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, enumArrays, jsonSerializerOptions); + WriteProperties(writer, enumArrays, jsonSerializerOptions); writer.WriteEndObject(); } @@ -322,7 +322,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs index 4cea89ad2853..043c59004595 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs @@ -829,7 +829,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, enumTest, jsonSerializerOptions); + WriteProperties(writer, enumTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -840,7 +840,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); writer.WriteString("enum_string_required", enumStringRequiredRawValue); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 67be73e69d8e..15e0e9658b52 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera { writer.WriteStartObject(); - WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions); + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs index e80532f6ca51..83a46bd772f4 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, file, jsonSerializerOptions); + WriteProperties(writer, file, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 05d6817a863e..1aacce8091e0 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema { writer.WriteStartObject(); - WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions); + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs index 2a4d7b8ea541..ca885a9ae071 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, foo, jsonSerializerOptions); + WriteProperties(writer, foo, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 1034e678d00d..1eb9f5b611cc 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe { writer.WriteStartObject(); - WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions); + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs index a36dbd28b87e..03a96c36410c 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs @@ -705,7 +705,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, formatTest, jsonSerializerOptions); + WriteProperties(writer, formatTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -716,7 +716,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs index 11be0a303ff3..6f71ce3a1e2a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs @@ -197,7 +197,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -208,7 +208,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FruitReq.cs index b8b8587d4bfb..30390ff4efa3 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FruitReq.cs @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, fruitReq, jsonSerializerOptions); + WriteProperties(writer, fruitReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -182,7 +182,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs index 358462ae67e4..ff9c67c07d81 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs @@ -205,16 +205,16 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, gmFruit, jsonSerializerOptions); + WriteProperties(writer, gmFruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -225,7 +225,7 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index a0068cc6781c..d92add7536ec 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -34,21 +34,20 @@ public partial class GrandparentAnimal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public GrandparentAnimal(string petType) + public GrandparentAnimal() { - PetType = petType; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public string PetType { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; /// /// Gets or Sets additional properties @@ -64,7 +63,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -115,6 +113,14 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t 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) @@ -145,7 +151,7 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); - return new GrandparentAnimal(petType.Value!); + return new GrandparentAnimal(); } /// @@ -157,9 +163,19 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t /// 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(ref writer, grandparentAnimal, jsonSerializerOptions); + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -170,11 +186,8 @@ public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentA /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { - if (grandparentAnimal.PetType == null) - throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); - writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 6be2aaf23180..4d44dedfd4a4 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -217,7 +217,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl { writer.WriteStartObject(); - WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions); + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -228,7 +228,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 4918784fef50..aeeb1a06d610 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR { writer.WriteStartObject(); - WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions); + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { if (healthCheckResult.NullableMessageOption.IsSet) if (healthCheckResult.NullableMessageOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 378561b5e325..d32a7e6d99b7 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri { writer.WriteStartObject(); - WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions); + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -172,7 +172,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs index 64ac2f962922..da1f349c9bde 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, list, jsonSerializerOptions); + WriteProperties(writer, list, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 34ce30c99fc1..64a2eb499d18 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri { writer.WriteStartObject(); - WriteProperties(ref writer, literalStringClass, jsonSerializerOptions); + WriteProperties(writer, literalStringClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs index 5b6c5f2e58e0..f80ef9bd3ebf 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs @@ -35,11 +35,9 @@ public partial class Mammal : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Whale whale, string className) + public Mammal(Whale whale) { Whale = whale; - ClassName = className; OnCreated(); } @@ -47,11 +45,9 @@ public Mammal(Whale whale, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Zebra zebra, string className) + public Mammal(Zebra zebra) { Zebra = zebra; - ClassName = className; OnCreated(); } @@ -59,11 +55,9 @@ public Mammal(Zebra zebra, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Pig pig, string className) + public Mammal(Pig pig) { Pig = pig; - ClassName = className; OnCreated(); } @@ -84,12 +78,6 @@ public Mammal(Pig pig, string className) /// public Pig? Pig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -104,7 +92,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -225,13 +212,13 @@ public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className.Value!); + return new Mammal(pig); if (whale != null) - return new Mammal(whale, className.Value!); + return new Mammal(whale); if (zebra != null) - return new Mammal(zebra, className.Value!); + return new Mammal(zebra); throw new JsonException(); } @@ -249,20 +236,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO if (mammal.Whale != null) { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); - whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } if (mammal.Zebra != null) { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); - zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } if (mammal.Pig != null) { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); - pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } - WriteProperties(ref writer, mammal, jsonSerializerOptions); + WriteProperties(writer, mammal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -273,12 +260,9 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { - if (mammal.ClassName == null) - throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); - writer.WriteString("className", mammal.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs index bcde97b65343..fdb5cd9a3732 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs @@ -292,7 +292,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, mapTest, jsonSerializerOptions); + WriteProperties(writer, mapTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -303,7 +303,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 0315c45e9bc9..01ef25c69ce8 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -238,7 +238,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -249,7 +249,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs index c2d66e9873fa..4cec514e74a0 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo { writer.WriteStartObject(); - WriteProperties(ref writer, model200Response, jsonSerializerOptions); + WriteProperties(writer, model200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs index 149e4bffc403..4c59b5d68c71 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, modelClient, jsonSerializerOptions); + WriteProperties(writer, modelClient, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs index 12fe5a128e08..a21af022df61 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs @@ -262,7 +262,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, name, jsonSerializerOptions); + WriteProperties(writer, name, jsonSerializerOptions); writer.WriteEndObject(); } @@ -273,7 +273,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index 0be2516e5112..f1322013ba86 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -170,7 +170,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R { writer.WriteStartObject(); - WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); writer.WriteEndObject(); } @@ -181,7 +181,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs index 5c4648d213fe..c674ba10f1b1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs @@ -397,7 +397,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, nullableClass, jsonSerializerOptions); + WriteProperties(writer, nullableClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -408,7 +408,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableGuidClass.cs index d32d8c31dbf6..6d21b7213d1b 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid { writer.WriteStartObject(); - WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions); + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { if (nullableGuidClass.UuidOption.IsSet) if (nullableGuidClass.UuidOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs index f77cc1947a12..5cb7a024bb8a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs @@ -35,11 +35,9 @@ public partial class NullableShape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Triangle triangle, string shapeType) + public NullableShape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -47,11 +45,9 @@ public NullableShape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Quadrilateral quadrilateral, string shapeType) + public NullableShape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -67,12 +63,6 @@ public NullableShape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -87,7 +77,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -202,10 +191,10 @@ public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType.Value!); + return new NullableShape(quadrilateral); if (triangle != null) - return new NullableShape(triangle, shapeType.Value!); + return new NullableShape(triangle); throw new JsonException(); } @@ -223,15 +212,15 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J if (nullableShape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } if (nullableShape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, nullableShape, jsonSerializerOptions); + WriteProperties(writer, nullableShape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -242,12 +231,9 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { - if (nullableShape.ShapeType == null) - throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); - writer.WriteString("shapeType", nullableShape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs index d11523b38f53..639f9226a106 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, numberOnly, jsonSerializerOptions); + WriteProperties(writer, numberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + 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/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index c20167f0f36f..8798637d31e3 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -228,7 +228,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj { writer.WriteStartObject(); - WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions); + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); writer.WriteEndObject(); } @@ -239,7 +239,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OneOfString.cs index 92cc112087e3..a2ab3d338802 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OneOfString.cs @@ -140,7 +140,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, oneOfString, jsonSerializerOptions); + WriteProperties(writer, oneOfString, jsonSerializerOptions); writer.WriteEndObject(); } @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs index df1d550cbf23..6fa4f95a8d99 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs @@ -363,7 +363,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, order, jsonSerializerOptions); + WriteProperties(writer, order, jsonSerializerOptions); writer.WriteEndObject(); } @@ -374,7 +374,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { if (order.CompleteOption.IsSet) writer.WriteBoolean("complete", order.CompleteOption.Value!.Value); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs index 6470fde6a2b6..8827863e100d 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -201,7 +201,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, { writer.WriteStartObject(); - WriteProperties(ref writer, outerComposite, jsonSerializerOptions); + WriteProperties(writer, outerComposite, jsonSerializerOptions); writer.WriteEndObject(); } @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ParentPet.cs index de4aa64ceab3..1b84966fe9b6 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ParentPet.cs @@ -34,15 +34,21 @@ public partial class ParentPet : GrandparentAnimal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public ParentPet(string petType) : base(petType) + 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 /// @@ -81,6 +87,11 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon 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) @@ -111,7 +122,7 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); - return new ParentPet(petType.Value!); + return new ParentPet(); } /// @@ -123,9 +134,14 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon /// public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + writer.WriteStartObject(); - WriteProperties(ref writer, parentPet, jsonSerializerOptions); + WriteProperties(writer, parentPet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -136,11 +152,8 @@ public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { - if (parentPet.PetType == null) - throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); - writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs index c04caa9bdec2..02c14e86b3d0 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs @@ -349,7 +349,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, pet, jsonSerializerOptions); + WriteProperties(writer, pet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -360,7 +360,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs index 727999c59285..0a26dc0fb341 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs @@ -35,11 +35,9 @@ public partial class Pig : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Pig(BasquePig basquePig, string className) + public Pig(BasquePig basquePig) { BasquePig = basquePig; - ClassName = className; OnCreated(); } @@ -47,11 +45,9 @@ public Pig(BasquePig basquePig, string className) /// Initializes a new instance of the class. /// /// - /// className - public Pig(DanishPig danishPig, string className) + public Pig(DanishPig danishPig) { DanishPig = danishPig; - ClassName = className; OnCreated(); } @@ -67,12 +63,6 @@ public Pig(DanishPig danishPig, string className) /// public DanishPig? DanishPig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -87,7 +77,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -202,10 +191,10 @@ public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className.Value!); + return new Pig(basquePig); if (danishPig != null) - return new Pig(danishPig, className.Value!); + return new Pig(danishPig); throw new JsonException(); } @@ -223,15 +212,15 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions if (pig.BasquePig != null) { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); - basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } if (pig.DanishPig != null) { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); - danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } - WriteProperties(ref writer, pig, jsonSerializerOptions); + WriteProperties(writer, pig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -242,12 +231,9 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { - if (pig.ClassName == null) - throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); - writer.WriteString("className", pig.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 351900a9dfd9..4466ad3cfe8a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -222,7 +222,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi { writer.WriteStartObject(); - WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions); + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); writer.WriteEndObject(); } @@ -233,7 +233,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs index e5bf2ef2a02c..bb00a21cf69a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -35,11 +35,9 @@ public partial class Quadrilateral : IValidatableObject /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType) + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { SimpleQuadrilateral = simpleQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -47,11 +45,9 @@ public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilater /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType) + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { ComplexQuadrilateral = complexQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -67,12 +63,6 @@ public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilat /// public ComplexQuadrilateral? ComplexQuadrilateral { get; set; } - /// - /// Gets or Sets QuadrilateralType - /// - [JsonPropertyName("quadrilateralType")] - public string QuadrilateralType { get; set; } - /// /// Gets or Sets additional properties /// @@ -87,7 +77,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -202,10 +191,10 @@ public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value!); + return new Quadrilateral(complexQuadrilateral); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value!); + return new Quadrilateral(simpleQuadrilateral); throw new JsonException(); } @@ -223,15 +212,15 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J if (quadrilateral.SimpleQuadrilateral != null) { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); - simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } if (quadrilateral.ComplexQuadrilateral != null) { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); - complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, quadrilateral, jsonSerializerOptions); + WriteProperties(writer, quadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -242,12 +231,9 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { - if (quadrilateral.QuadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); - writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 9a15b8828a38..bc88c7d59196 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril { writer.WriteStartObject(); - WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions); + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index c34d7d3e3095..ad4b61f5e025 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -214,7 +214,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J { writer.WriteStartObject(); - WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions); + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); writer.WriteEndObject(); } @@ -225,7 +225,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs index 87283acb06b6..ef54b52d7351 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -2158,7 +2158,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + WriteProperties(writer, requiredClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -2169,7 +2169,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs index f1be8615789b..858b9afb4f51 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ { writer.WriteStartObject(); - WriteProperties(ref writer, varReturn, jsonSerializerOptions); + WriteProperties(writer, varReturn, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 6bd85b0b2fb6..a542e79114b3 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index b25f95d28d94..b7e2f743a1d9 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 4cdb6d4aa46d..3cec323bc5d2 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl { writer.WriteStartObject(); - WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions); + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs index a8043ce2c4c5..c19f3a8af06a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs @@ -35,11 +35,9 @@ public partial class Shape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Triangle triangle, string shapeType) + public Shape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -47,11 +45,9 @@ public Shape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Quadrilateral quadrilateral, string shapeType) + public Shape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -67,12 +63,6 @@ public Shape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -87,7 +77,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -202,10 +191,10 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType.Value!); + return new Shape(quadrilateral); if (triangle != null) - return new Shape(triangle, shapeType.Value!); + return new Shape(triangle); throw new JsonException(); } @@ -223,15 +212,15 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt if (shape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } if (shape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shape, jsonSerializerOptions); + WriteProperties(writer, shape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -242,12 +231,9 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { - if (shape.ShapeType == null) - throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); - writer.WriteString("shapeType", shape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs index 2780ac574a8d..449c74ed5964 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, { writer.WriteStartObject(); - WriteProperties(ref writer, shapeInterface, jsonSerializerOptions); + WriteProperties(writer, shapeInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs index d05ff4a70d75..e6d8735bd1ba 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -35,11 +35,9 @@ public partial class ShapeOrNull : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Triangle triangle, string shapeType) + public ShapeOrNull(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -47,11 +45,9 @@ public ShapeOrNull(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) + public ShapeOrNull(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -67,12 +63,6 @@ public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -87,7 +77,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -202,10 +191,10 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType.Value!); + return new ShapeOrNull(quadrilateral); if (triangle != null) - return new ShapeOrNull(triangle, shapeType.Value!); + return new ShapeOrNull(triangle); throw new JsonException(); } @@ -223,15 +212,15 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS if (shapeOrNull.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } if (shapeOrNull.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions); + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); writer.WriteEndObject(); } @@ -242,12 +231,9 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { - if (shapeOrNull.ShapeType == null) - throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); - writer.WriteString("shapeType", shapeOrNull.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index 279d0b1faa0b..1ccbce2b791d 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad { writer.WriteStartObject(); - WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs index 4d20d3fb6e16..3af779a4e603 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN { writer.WriteStartObject(); - WriteProperties(ref writer, specialModelName, jsonSerializerOptions); + WriteProperties(writer, specialModelName, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs index e2b68cf0ef2c..8878770aede1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, tag, jsonSerializerOptions); + WriteProperties(writer, tag, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index 8906009c84e6..9b7baf9d290a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 9fc973037f6f..1ec54dc3f9ae 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index d4ebe81bb05d..b1ff0c9f49da 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs index 303afee787db..4d8f03d60a0b 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs @@ -35,11 +35,9 @@ public partial class Triangle : IValidatableObject /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) + public Triangle(EquilateralTriangle equilateralTriangle) { EquilateralTriangle = equilateralTriangle; - TriangleType = triangleType; OnCreated(); } @@ -47,11 +45,9 @@ public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) + public Triangle(IsoscelesTriangle isoscelesTriangle) { IsoscelesTriangle = isoscelesTriangle; - TriangleType = triangleType; OnCreated(); } @@ -59,11 +55,9 @@ public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) + public Triangle(ScaleneTriangle scaleneTriangle) { ScaleneTriangle = scaleneTriangle; - TriangleType = triangleType; OnCreated(); } @@ -84,12 +78,6 @@ public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) /// public ScaleneTriangle? ScaleneTriangle { get; set; } - /// - /// Gets or Sets TriangleType - /// - [JsonPropertyName("triangleType")] - public string TriangleType { get; set; } - /// /// Gets or Sets additional properties /// @@ -104,7 +92,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -225,13 +212,13 @@ public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType.Value!); + return new Triangle(equilateralTriangle); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType.Value!); + return new Triangle(isoscelesTriangle); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType.Value!); + return new Triangle(scaleneTriangle); throw new JsonException(); } @@ -249,20 +236,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali if (triangle.EquilateralTriangle != null) { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); - equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } if (triangle.IsoscelesTriangle != null) { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); - isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } if (triangle.ScaleneTriangle != null) { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); - scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } - WriteProperties(ref writer, triangle, jsonSerializerOptions); + WriteProperties(writer, triangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -273,12 +260,9 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { - if (triangle.TriangleType == null) - throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); - writer.WriteString("triangleType", triangle.TriangleType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs index f5bb5d307c83..056926c5eda5 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte { writer.WriteStartObject(); - WriteProperties(ref writer, triangleInterface, jsonSerializerOptions); + WriteProperties(writer, triangleInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -160,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs index 2fa45a9c00a0..384fc9e1cc5d 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs @@ -408,7 +408,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, user, jsonSerializerOptions); + WriteProperties(writer, user, jsonSerializerOptions); writer.WriteEndObject(); } @@ -419,7 +419,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs index 6f1ab62d256a..b30219575b8b 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs @@ -197,7 +197,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, whale, jsonSerializerOptions); + WriteProperties(writer, whale, jsonSerializerOptions); writer.WriteEndObject(); } @@ -208,7 +208,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs index 92726ea411e5..06b58fe19558 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs @@ -254,7 +254,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, zebra, jsonSerializerOptions); + WriteProperties(writer, zebra, jsonSerializerOptions); writer.WriteEndObject(); } @@ -265,7 +265,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 3c4832e9a360..bb38eafb4685 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -221,7 +221,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn { writer.WriteStartObject(); - WriteProperties(ref writer, zeroBasedEnumClass, jsonSerializerOptions); + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -232,7 +232,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs index 57169a68de3b..906cd9937170 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -266,6 +266,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs index e933186d8e08..c887090b6ca7 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs index 102dc422c2e4..ad5d19ad12d5 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs index bd718d56cbed..c39e0c72912f 100644 --- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs @@ -204,7 +204,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -215,7 +215,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index a3bedb429297..b641364215ef 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -359,6 +359,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs index 2ed0cacfe1ee..b746b781c3e2 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Activity.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, activity, jsonSerializerOptions); + WriteProperties(writer, activity, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index e51af3a1a80d..3afdabfc6d58 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent { writer.WriteStartObject(); - WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions); + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 8aecec6328ed..b422890b171c 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -318,7 +318,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi { writer.WriteStartObject(); - WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -329,7 +329,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs index 700f201cf894..aea749057480 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Animal.cs @@ -32,12 +32,10 @@ public partial class Animal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, Option color = default) + public Animal(Option color = default) { - ClassName = className; ColorOption = color; OnCreated(); } @@ -45,10 +43,11 @@ public Animal(string className, Option color = default) partial void OnCreated(); /// - /// Gets or Sets ClassName + /// The discriminator /// - [JsonPropertyName("className")] - public string ClassName { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; /// /// Used to track the state of Color @@ -77,7 +76,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); @@ -130,6 +128,14 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -166,7 +172,7 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); - return new Animal(className.Value, color); + return new Animal(color); } /// @@ -178,9 +184,19 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, animal, jsonSerializerOptions); + WriteProperties(writer, animal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -191,11 +207,8 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { - if (animal.ClassName == null) - throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); - if (animal.ColorOption.IsSet && animal.Color == null) throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs index 84fa6eef72ca..02c11a9a77ee 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -198,7 +198,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, apiResponse, jsonSerializerOptions); + WriteProperties(writer, apiResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -209,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs index 233ec205fd33..59e078d0a8dd 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Apple.cs @@ -227,7 +227,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -238,7 +238,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs index eccab20bd13d..9801b197763e 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, appleReq, jsonSerializerOptions); + WriteProperties(writer, appleReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index 2935b372eee1..7decd736dd63 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 1e028acb226c..d9c4bbd05e49 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs index f0990197e1d7..0d5cf364c0bf 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -200,7 +200,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, arrayTest, jsonSerializerOptions); + WriteProperties(writer, arrayTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -211,7 +211,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs index 773f3d09bf95..5deb7b3cabb7 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Banana.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs index d8b91e33ae20..1ead980e60ac 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, bananaReq, jsonSerializerOptions); + WriteProperties(writer, bananaReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs index 53c20a25cd10..863cc82bc782 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, basquePig, jsonSerializerOptions); + WriteProperties(writer, basquePig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs index fe9e72647b7d..5ee27d790d1e 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs @@ -267,7 +267,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, { writer.WriteStartObject(); - WriteProperties(ref writer, capitalization, jsonSerializerOptions); + WriteProperties(writer, capitalization, jsonSerializerOptions); writer.WriteEndObject(); } @@ -278,7 +278,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs index b60c6b69a4e3..33d826fa7ea9 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Cat.cs @@ -32,11 +32,10 @@ public partial class Cat : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") /// declawed [JsonConstructor] - public Cat(string className, Option color = default, Option declawed = default) : base(className, color) + public Cat(Option color = default, Option declawed = default) : base(color) { DeclawedOption = declawed; OnCreated(); @@ -44,6 +43,13 @@ public Cat(string className, Option color = default, Option decla 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 /// @@ -141,7 +147,7 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (declawed.IsSet && declawed.Value == null) throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); - return new Cat(className.Value, color, declawed); + return new Cat(color, declawed); } /// @@ -155,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, cat, jsonSerializerOptions); + WriteProperties(writer, cat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,11 +172,8 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { - if (cat.ClassName == null) - throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); - if (cat.ColorOption.IsSet && cat.Color == null) throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs index a880d914ef00..646d804623a3 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Category.cs @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, category, jsonSerializerOptions); + WriteProperties(writer, category, jsonSerializerOptions); writer.WriteEndObject(); } @@ -182,7 +182,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs index 4c6932c5672b..af2778ca5463 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs @@ -33,12 +33,10 @@ public partial class ChildCat : ParentPet, IValidatableObject /// Initializes a new instance of the class. /// /// name - /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default) : base() { NameOption = name; - PetType = petType; OnCreated(); } @@ -96,12 +94,6 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets PetType - /// - [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } - /// /// Used to track the state of Name /// @@ -115,6 +107,13 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) [JsonPropertyName("name")] public string Name { get { return this.NameOption; } set { this.NameOption = new(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 /// @@ -125,7 +124,6 @@ public override string ToString() sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -194,7 +192,7 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value.Value); + return new ChildCat(name); } /// @@ -208,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, childCat, jsonSerializerOptions); + WriteProperties(writer, childCat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -219,7 +217,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -227,8 +225,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSe if (childCat.NameOption.IsSet) writer.WriteString("name", childCat.Name); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); - writer.WriteString("pet_type", petTypeRawValue); + writer.WriteString("pet_type", ChildCat.PetTypeEnumToJsonValue(childCat.PetType)); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs index 31f98f66f508..3740f80f7c4f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, classModel, jsonSerializerOptions); + WriteProperties(writer, classModel, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 747b36ec65bd..1a42f967ca91 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu { writer.WriteStartObject(); - WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs index c28634e4e13e..9eb8b733358d 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, danishPig, jsonSerializerOptions); + WriteProperties(writer, danishPig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 7d7789e3d8d4..4f3c74c26d9e 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions); + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 2db62c460fc1..1ffcd1e09a87 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj { writer.WriteStartObject(); - WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions); + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs index cafd49dfda84..ee6d230b265a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Dog.cs @@ -32,11 +32,10 @@ public partial class Dog : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// breed /// color (default to "red") [JsonConstructor] - public Dog(string className, Option breed = default, Option color = default) : base(className, color) + public Dog(Option breed = default, Option color = default) : base(color) { BreedOption = breed; OnCreated(); @@ -44,6 +43,13 @@ public Dog(string className, Option breed = default, Option colo 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 /// @@ -140,7 +146,7 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); - return new Dog(className.Value, breed, color); + return new Dog(breed, color); } /// @@ -154,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, dog, jsonSerializerOptions); + WriteProperties(writer, dog, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,11 +171,8 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - if (dog.ClassName == null) - throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); - if (dog.BreedOption.IsSet && dog.Breed == null) throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 29aaebc2075c..e5f2fb7e0258 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -218,7 +218,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, drawing, jsonSerializerOptions); + WriteProperties(writer, drawing, jsonSerializerOptions); writer.WriteEndObject(); } @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs index 06bce62a3891..5a16d41c18af 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -309,7 +309,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, enumArrays, jsonSerializerOptions); + WriteProperties(writer, enumArrays, jsonSerializerOptions); writer.WriteEndObject(); } @@ -320,7 +320,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs index 9fadfdcbf354..7d899ce52328 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs @@ -827,7 +827,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, enumTest, jsonSerializerOptions); + WriteProperties(writer, enumTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -838,7 +838,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); writer.WriteString("enum_string_required", enumStringRequiredRawValue); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index bbf4bf8f8e09..b84f89b531dc 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera { writer.WriteStartObject(); - WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions); + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs index dc4ffdfe56b8..49cc4b73830a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/File.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, file, jsonSerializerOptions); + WriteProperties(writer, file, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 29f6d03ffd07..4c22995b6051 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema { writer.WriteStartObject(); - WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions); + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs index 21dba9216639..2b59206330a8 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Foo.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, foo, jsonSerializerOptions); + WriteProperties(writer, foo, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 21585e839d6f..42d40f715ec0 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe { writer.WriteStartObject(); - WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions); + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs index 24cc7c3f39b6..545fe1a83b67 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs @@ -703,7 +703,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, formatTest, jsonSerializerOptions); + WriteProperties(writer, formatTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -714,7 +714,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs index 1c491c62a5ac..d39d2a29ad8a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Fruit.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs index 03ef926c47d4..f5dd6d56278f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, fruitReq, jsonSerializerOptions); + WriteProperties(writer, fruitReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs index b0ff469057d2..95772b5635b8 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs @@ -203,16 +203,16 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, gmFruit, jsonSerializerOptions); + WriteProperties(writer, gmFruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 6b7d7ae8da68..86246ae54570 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -32,21 +32,20 @@ public partial class GrandparentAnimal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public GrandparentAnimal(string petType) + public GrandparentAnimal() { - PetType = petType; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public string PetType { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; /// /// Gets or Sets additional properties @@ -62,7 +61,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -113,6 +111,14 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t 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) @@ -143,7 +149,7 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); - return new GrandparentAnimal(petType.Value); + return new GrandparentAnimal(); } /// @@ -155,9 +161,19 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t /// 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(ref writer, grandparentAnimal, jsonSerializerOptions); + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -168,11 +184,8 @@ public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentA /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { - if (grandparentAnimal.PetType == null) - throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); - writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index a58bd7569681..88c5d4274eab 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -215,7 +215,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl { writer.WriteStartObject(); - WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions); + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 2c7412692513..0c916b0a208e 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -148,7 +148,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR { writer.WriteStartObject(); - WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions); + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { if (healthCheckResult.NullableMessageOption.IsSet) if (healthCheckResult.NullableMessageOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 3f4aa3229c4e..384e48f3a155 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri { writer.WriteStartObject(); - WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions); + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -170,7 +170,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs index cbdf361981be..b4f4f31b7fd8 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/List.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, list, jsonSerializerOptions); + WriteProperties(writer, list, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 25c7ef39a736..9e1a7878ad50 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -174,7 +174,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri { writer.WriteStartObject(); - WriteProperties(ref writer, literalStringClass, jsonSerializerOptions); + WriteProperties(writer, literalStringClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -185,7 +185,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 05e439a9c3e6..1be5661d9936 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -33,11 +33,9 @@ public partial class Mammal : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Whale whale, string className) + public Mammal(Whale whale) { Whale = whale; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Mammal(Whale whale, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Zebra zebra, string className) + public Mammal(Zebra zebra) { Zebra = zebra; - ClassName = className; OnCreated(); } @@ -57,11 +53,9 @@ public Mammal(Zebra zebra, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Pig pig, string className) + public Mammal(Pig pig) { Pig = pig; - ClassName = className; OnCreated(); } @@ -82,12 +76,6 @@ public Mammal(Pig pig, string className) /// public Pig Pig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className.Value); + return new Mammal(pig); if (whale != null) - return new Mammal(whale, className.Value); + return new Mammal(whale); if (zebra != null) - return new Mammal(zebra, className.Value); + return new Mammal(zebra); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO if (mammal.Whale != null) { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); - whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } if (mammal.Zebra != null) { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); - zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } if (mammal.Pig != null) { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); - pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } - WriteProperties(ref writer, mammal, jsonSerializerOptions); + WriteProperties(writer, mammal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { - if (mammal.ClassName == null) - throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); - writer.WriteString("className", mammal.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs index 14614620d4ed..6fa8d54e7f73 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MapTest.cs @@ -290,7 +290,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, mapTest, jsonSerializerOptions); + WriteProperties(writer, mapTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -301,7 +301,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 5effb3c63c55..ae423667629f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -236,7 +236,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -247,7 +247,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs index 6447826e7d8c..f503204de208 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo { writer.WriteStartObject(); - WriteProperties(ref writer, model200Response, jsonSerializerOptions); + WriteProperties(writer, model200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs index 1c3b4cf30db3..cac0963a2014 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, modelClient, jsonSerializerOptions); + WriteProperties(writer, modelClient, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs index 083a7233e15c..86bbf24f53a5 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Name.cs @@ -260,7 +260,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, name, jsonSerializerOptions); + WriteProperties(writer, name, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,7 +271,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index cd1516104e35..d10268f2927a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R { writer.WriteStartObject(); - WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs index e5aa83541370..fcafbb947441 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs @@ -395,7 +395,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, nullableClass, jsonSerializerOptions); + WriteProperties(writer, nullableClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs index e4ecd87be6a5..4b5f815656a8 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid { writer.WriteStartObject(); - WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions); + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { if (nullableGuidClass.UuidOption.IsSet) if (nullableGuidClass.UuidOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index d66595994262..10061a2c228b 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -33,11 +33,9 @@ public partial class NullableShape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Triangle triangle, string shapeType) + public NullableShape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public NullableShape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Quadrilateral quadrilateral, string shapeType) + public NullableShape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public NullableShape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType.Value); + return new NullableShape(quadrilateral); if (triangle != null) - return new NullableShape(triangle, shapeType.Value); + return new NullableShape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J if (nullableShape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } if (nullableShape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, nullableShape, jsonSerializerOptions); + WriteProperties(writer, nullableShape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { - if (nullableShape.ShapeType == null) - throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); - writer.WriteString("shapeType", nullableShape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs index b54928bcca58..15c9e5cbfcbb 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, numberOnly, jsonSerializerOptions); + WriteProperties(writer, numberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + 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/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 8dc4e4d1b9e2..b25d9e5fd872 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj { writer.WriteStartObject(); - WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions); + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); writer.WriteEndObject(); } @@ -237,7 +237,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs index 258453564b0b..0f4f13f311b0 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs @@ -138,7 +138,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, oneOfString, jsonSerializerOptions); + WriteProperties(writer, oneOfString, jsonSerializerOptions); writer.WriteEndObject(); } @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs index cb5255ea581a..96177e75bb79 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Order.cs @@ -361,7 +361,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, order, jsonSerializerOptions); + WriteProperties(writer, order, jsonSerializerOptions); writer.WriteEndObject(); } @@ -372,7 +372,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { if (order.CompleteOption.IsSet) writer.WriteBoolean("complete", order.CompleteOption.Value.Value); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs index c4592b634a36..daa467e228b5 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -199,7 +199,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, { writer.WriteStartObject(); - WriteProperties(ref writer, outerComposite, jsonSerializerOptions); + WriteProperties(writer, outerComposite, jsonSerializerOptions); writer.WriteEndObject(); } @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs index c451e1a8991b..5d1cab769fa8 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs @@ -32,15 +32,21 @@ public partial class ParentPet : GrandparentAnimal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public ParentPet(string petType) : base(petType) + 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 /// @@ -79,6 +85,11 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon 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) @@ -109,7 +120,7 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); - return new ParentPet(petType.Value); + return new ParentPet(); } /// @@ -121,9 +132,14 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon /// public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + writer.WriteStartObject(); - WriteProperties(ref writer, parentPet, jsonSerializerOptions); + WriteProperties(writer, parentPet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -134,11 +150,8 @@ public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { - if (parentPet.PetType == null) - throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); - writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs index 2ed38395a76b..bc11d7e054d4 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pet.cs @@ -347,7 +347,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, pet, jsonSerializerOptions); + WriteProperties(writer, pet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -358,7 +358,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs index d3bbeb8ff326..19e395f1de47 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -33,11 +33,9 @@ public partial class Pig : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Pig(BasquePig basquePig, string className) + public Pig(BasquePig basquePig) { BasquePig = basquePig; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Pig(BasquePig basquePig, string className) /// Initializes a new instance of the class. /// /// - /// className - public Pig(DanishPig danishPig, string className) + public Pig(DanishPig danishPig) { DanishPig = danishPig; - ClassName = className; OnCreated(); } @@ -65,12 +61,6 @@ public Pig(DanishPig danishPig, string className) /// public DanishPig DanishPig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className.Value); + return new Pig(basquePig); if (danishPig != null) - return new Pig(danishPig, className.Value); + return new Pig(danishPig); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions if (pig.BasquePig != null) { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); - basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } if (pig.DanishPig != null) { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); - danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } - WriteProperties(ref writer, pig, jsonSerializerOptions); + WriteProperties(writer, pig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { - if (pig.ClassName == null) - throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); - writer.WriteString("className", pig.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 0c176589d063..30edd0b77d2d 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -220,7 +220,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi { writer.WriteStartObject(); - WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions); + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); writer.WriteEndObject(); } @@ -231,7 +231,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index f3ef21718ae4..3d333d7958fb 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -33,11 +33,9 @@ public partial class Quadrilateral : IValidatableObject /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType) + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { SimpleQuadrilateral = simpleQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -45,11 +43,9 @@ public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilater /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType) + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { ComplexQuadrilateral = complexQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -65,12 +61,6 @@ public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilat /// public ComplexQuadrilateral ComplexQuadrilateral { get; set; } - /// - /// Gets or Sets QuadrilateralType - /// - [JsonPropertyName("quadrilateralType")] - public string QuadrilateralType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(complexQuadrilateral); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(simpleQuadrilateral); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J if (quadrilateral.SimpleQuadrilateral != null) { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); - simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } if (quadrilateral.ComplexQuadrilateral != null) { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); - complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, quadrilateral, jsonSerializerOptions); + WriteProperties(writer, quadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { - if (quadrilateral.QuadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); - writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 75b7e516cfca..610005a05408 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril { writer.WriteStartObject(); - WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions); + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 46c7177ca57e..5ef0b0448074 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J { writer.WriteStartObject(); - WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions); + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs index e534142196e9..5456c1d1422b 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -2156,7 +2156,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + WriteProperties(writer, requiredClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -2167,7 +2167,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs index 5804b46eff20..30c6b4d7fe9b 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Return.cs @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ { writer.WriteStartObject(); - WriteProperties(ref writer, varReturn, jsonSerializerOptions); + WriteProperties(writer, varReturn, jsonSerializerOptions); writer.WriteEndObject(); } @@ -221,7 +221,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 306c5b8f7278..14e2d9ee12fa 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index 763295f24971..1e19e81e55c5 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 52a8e0d69c60..47081ede38ef 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl { writer.WriteStartObject(); - WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions); + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs index ffd95a8fdff1..d4883a363a21 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -33,11 +33,9 @@ public partial class Shape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Triangle triangle, string shapeType) + public Shape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public Shape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Quadrilateral quadrilateral, string shapeType) + public Shape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public Shape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType.Value); + return new Shape(quadrilateral); if (triangle != null) - return new Shape(triangle, shapeType.Value); + return new Shape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt if (shape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } if (shape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shape, jsonSerializerOptions); + WriteProperties(writer, shape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { - if (shape.ShapeType == null) - throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); - writer.WriteString("shapeType", shape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs index 5bd364cc6a41..3027d9142baf 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, { writer.WriteStartObject(); - WriteProperties(ref writer, shapeInterface, jsonSerializerOptions); + WriteProperties(writer, shapeInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index d60f396c70da..2d9fb2cbb334 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -33,11 +33,9 @@ public partial class ShapeOrNull : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Triangle triangle, string shapeType) + public ShapeOrNull(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public ShapeOrNull(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) + public ShapeOrNull(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType.Value); + return new ShapeOrNull(quadrilateral); if (triangle != null) - return new ShapeOrNull(triangle, shapeType.Value); + return new ShapeOrNull(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS if (shapeOrNull.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } if (shapeOrNull.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions); + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { - if (shapeOrNull.ShapeType == null) - throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); - writer.WriteString("shapeType", shapeOrNull.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index a00a87e2efa5..3fa8bdc19177 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad { writer.WriteStartObject(); - WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs index e90c6487364f..0cc19a946de1 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN { writer.WriteStartObject(); - WriteProperties(ref writer, specialModelName, jsonSerializerOptions); + WriteProperties(writer, specialModelName, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs index 84f19a2c8988..5c64df495c19 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Tag.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, tag, jsonSerializerOptions); + WriteProperties(writer, tag, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index 73886a2eca06..c5e4293dca4e 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 599b515add99..798a4b835c90 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 1e3b57bfe36a..e6590dd351db 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index 737124e080b3..d31d2948c652 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -33,11 +33,9 @@ public partial class Triangle : IValidatableObject /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) + public Triangle(EquilateralTriangle equilateralTriangle) { EquilateralTriangle = equilateralTriangle; - TriangleType = triangleType; OnCreated(); } @@ -45,11 +43,9 @@ public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) + public Triangle(IsoscelesTriangle isoscelesTriangle) { IsoscelesTriangle = isoscelesTriangle; - TriangleType = triangleType; OnCreated(); } @@ -57,11 +53,9 @@ public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) + public Triangle(ScaleneTriangle scaleneTriangle) { ScaleneTriangle = scaleneTriangle; - TriangleType = triangleType; OnCreated(); } @@ -82,12 +76,6 @@ public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) /// public ScaleneTriangle ScaleneTriangle { get; set; } - /// - /// Gets or Sets TriangleType - /// - [JsonPropertyName("triangleType")] - public string TriangleType { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType.Value); + return new Triangle(equilateralTriangle); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType.Value); + return new Triangle(isoscelesTriangle); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType.Value); + return new Triangle(scaleneTriangle); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali if (triangle.EquilateralTriangle != null) { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); - equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } if (triangle.IsoscelesTriangle != null) { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); - isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } if (triangle.ScaleneTriangle != null) { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); - scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } - WriteProperties(ref writer, triangle, jsonSerializerOptions); + WriteProperties(writer, triangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { - if (triangle.TriangleType == null) - throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); - writer.WriteString("triangleType", triangle.TriangleType); } } } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs index 270c598de618..aa6d31b91909 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte { writer.WriteStartObject(); - WriteProperties(ref writer, triangleInterface, jsonSerializerOptions); + WriteProperties(writer, triangleInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs index 22330c4f5a8f..ea5842d39f41 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/User.cs @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, user, jsonSerializerOptions); + WriteProperties(writer, user, jsonSerializerOptions); writer.WriteEndObject(); } @@ -417,7 +417,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs index b130c0fbf886..258c1713bcc2 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Whale.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, whale, jsonSerializerOptions); + WriteProperties(writer, whale, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs index b8be0d28b132..496d18a90ea3 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Zebra.cs @@ -252,7 +252,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, zebra, jsonSerializerOptions); + WriteProperties(writer, zebra, jsonSerializerOptions); writer.WriteEndObject(); } @@ -263,7 +263,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 511fa98fa5fd..d2b2ebeeb83f 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -219,7 +219,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn { writer.WriteStartObject(); - WriteProperties(ref writer, zeroBasedEnumClass, jsonSerializerOptions); + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -230,7 +230,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index 7c68fd649ffd..6a08eb32a3a7 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -361,6 +361,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs index 04a319484ff2..5b176f5847b0 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, activity, jsonSerializerOptions); + WriteProperties(writer, activity, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index 5d8247aa3b3e..4c1d4719e88d 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent { writer.WriteStartObject(); - WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions); + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 46263182a1d8..6213c117b3d5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -321,7 +321,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi { writer.WriteStartObject(); - WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -332,7 +332,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs index a82a1cc253c4..950bb12e8ce5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs @@ -35,12 +35,10 @@ public partial class Animal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, Option color = default) + public Animal(Option color = default) { - ClassName = className; ColorOption = color; OnCreated(); } @@ -48,10 +46,11 @@ public Animal(string className, Option color = default) partial void OnCreated(); /// - /// Gets or Sets ClassName + /// The discriminator /// - [JsonPropertyName("className")] - public string ClassName { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; /// /// Used to track the state of Color @@ -80,7 +79,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); @@ -133,6 +131,14 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -169,7 +175,7 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); - return new Animal(className.Value!, color); + return new Animal(color); } /// @@ -181,9 +187,19 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, animal, jsonSerializerOptions); + WriteProperties(writer, animal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -194,11 +210,8 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { - if (animal.ClassName == null) - throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); - if (animal.ColorOption.IsSet && animal.Color == null) throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs index 794b53168b5b..fe7efa6f1aa7 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -201,7 +201,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, apiResponse, jsonSerializerOptions); + WriteProperties(writer, apiResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs index aa181299bc07..71ef8c147c46 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs @@ -230,7 +230,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -241,7 +241,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs index 6107920df4bf..7e88ecdde6b5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs @@ -167,7 +167,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, appleReq, jsonSerializerOptions); + WriteProperties(writer, appleReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index abbbaf46bfb2..b19b1457e95e 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 9488591f76eb..db1e09392db4 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs index b60359f36256..d2b761acf711 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -203,7 +203,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, arrayTest, jsonSerializerOptions); + WriteProperties(writer, arrayTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -214,7 +214,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs index 9ebe18e0ea22..57ed00dc7159 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs index fbb8eabc47f5..4c3b455b4d8c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, bananaReq, jsonSerializerOptions); + WriteProperties(writer, bananaReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs index bf0cea7cd565..51068cfa79a7 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BasquePig.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, basquePig, jsonSerializerOptions); + WriteProperties(writer, basquePig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs index 34db2b723865..052c859a180e 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs @@ -270,7 +270,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, { writer.WriteStartObject(); - WriteProperties(ref writer, capitalization, jsonSerializerOptions); + WriteProperties(writer, capitalization, jsonSerializerOptions); writer.WriteEndObject(); } @@ -281,7 +281,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs index 0d2c9ae1f5c4..359c2d982424 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs @@ -35,11 +35,10 @@ public partial class Cat : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") /// declawed [JsonConstructor] - public Cat(string className, Option color = default, Option declawed = default) : base(className, color) + public Cat(Option color = default, Option declawed = default) : base(color) { DeclawedOption = declawed; OnCreated(); @@ -47,6 +46,13 @@ public Cat(string className, Option color = default, Option decl 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 /// @@ -144,7 +150,7 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (declawed.IsSet && declawed.Value == null) throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); - return new Cat(className.Value!, color, declawed); + return new Cat(color, declawed); } /// @@ -158,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, cat, jsonSerializerOptions); + WriteProperties(writer, cat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -169,11 +175,8 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { - if (cat.ClassName == null) - throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); - if (cat.ColorOption.IsSet && cat.Color == null) throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs index 6cec2c557de8..90e66ff54e44 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs @@ -174,7 +174,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, category, jsonSerializerOptions); + WriteProperties(writer, category, jsonSerializerOptions); writer.WriteEndObject(); } @@ -185,7 +185,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs index 5c0e41fe82bb..62bd1e479557 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs @@ -36,12 +36,10 @@ public partial class ChildCat : ParentPet, IValidatableObject /// Initializes a new instance of the class. /// /// name - /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default) : base() { NameOption = name; - PetType = petType; OnCreated(); } @@ -99,12 +97,6 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets PetType - /// - [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } - /// /// Used to track the state of Name /// @@ -118,6 +110,13 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) [JsonPropertyName("name")] public string? Name { get { return this.NameOption; } set { this.NameOption = new(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 /// @@ -128,7 +127,6 @@ public override string ToString() sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -197,7 +195,7 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value!.Value!); + return new ChildCat(name); } /// @@ -211,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, childCat, jsonSerializerOptions); + WriteProperties(writer, childCat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -222,7 +220,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -230,8 +228,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSe if (childCat.NameOption.IsSet) writer.WriteString("name", childCat.Name); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); - writer.WriteString("pet_type", petTypeRawValue); + writer.WriteString("pet_type", ChildCat.PetTypeEnumToJsonValue(childCat.PetType)); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs index c04872746648..0a3fdbfb454a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, classModel, jsonSerializerOptions); + WriteProperties(writer, classModel, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 51888deccf75..07c7479edd97 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu { writer.WriteStartObject(); - WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs index eed526c69f59..e1f21a8c8d49 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DanishPig.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, danishPig, jsonSerializerOptions); + WriteProperties(writer, danishPig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 61673c1d85ec..c6c77d2d6a88 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions); + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -172,7 +172,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs index 5eba41f29d28..f2fecb27023a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj { writer.WriteStartObject(); - WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions); + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs index e8f095cbf725..b0cf0bc10c4e 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs @@ -35,11 +35,10 @@ public partial class Dog : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// breed /// color (default to "red") [JsonConstructor] - public Dog(string className, Option breed = default, Option color = default) : base(className, color) + public Dog(Option breed = default, Option color = default) : base(color) { BreedOption = breed; OnCreated(); @@ -47,6 +46,13 @@ public Dog(string className, Option breed = default, Option co 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 /// @@ -143,7 +149,7 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); - return new Dog(className.Value!, breed, color); + return new Dog(breed, color); } /// @@ -157,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, dog, jsonSerializerOptions); + WriteProperties(writer, dog, jsonSerializerOptions); writer.WriteEndObject(); } @@ -168,11 +174,8 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - if (dog.ClassName == null) - throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); - if (dog.BreedOption.IsSet && dog.Breed == null) throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs index 7121de5155ac..f748a54b9725 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs @@ -221,7 +221,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, drawing, jsonSerializerOptions); + WriteProperties(writer, drawing, jsonSerializerOptions); writer.WriteEndObject(); } @@ -232,7 +232,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs index 2c2f2c2c5fc2..da63470bbc78 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -312,7 +312,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, enumArrays, jsonSerializerOptions); + WriteProperties(writer, enumArrays, jsonSerializerOptions); writer.WriteEndObject(); } @@ -323,7 +323,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs index d7d18dcad39a..d7d03540d338 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs @@ -830,7 +830,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, enumTest, jsonSerializerOptions); + WriteProperties(writer, enumTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -841,7 +841,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); writer.WriteString("enum_string_required", enumStringRequiredRawValue); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index 6b6bfc6728ba..39b32f1ba22f 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera { writer.WriteStartObject(); - WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions); + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs index c9e1e2536737..cc0ffd3e033c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, file, jsonSerializerOptions); + WriteProperties(writer, file, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index 37d56cfbb848..c48ca22ddc83 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema { writer.WriteStartObject(); - WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions); + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -190,7 +190,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs index d7b6cae2587a..65826736eb9b 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, foo, jsonSerializerOptions); + WriteProperties(writer, foo, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 78fc72669173..ca7d6abeadeb 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe { writer.WriteStartObject(); - WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions); + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs index f5b11b31afe2..2274b53efdff 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs @@ -706,7 +706,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, formatTest, jsonSerializerOptions); + WriteProperties(writer, formatTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -717,7 +717,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs index 582edf903a48..3331b736cfc1 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs @@ -198,7 +198,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -209,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FruitReq.cs index 570b86e0050d..c2942aea0f48 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FruitReq.cs @@ -172,7 +172,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, fruitReq, jsonSerializerOptions); + WriteProperties(writer, fruitReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -183,7 +183,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs index e00086e3d474..112112a55b58 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs @@ -206,16 +206,16 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, gmFruit, jsonSerializerOptions); + WriteProperties(writer, gmFruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index e2a86feac42d..12a7ac828e27 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -35,21 +35,20 @@ public partial class GrandparentAnimal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public GrandparentAnimal(string petType) + public GrandparentAnimal() { - PetType = petType; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public string PetType { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; /// /// Gets or Sets additional properties @@ -65,7 +64,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -116,6 +114,14 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t 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) @@ -146,7 +152,7 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); - return new GrandparentAnimal(petType.Value!); + return new GrandparentAnimal(); } /// @@ -158,9 +164,19 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t /// 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(ref writer, grandparentAnimal, jsonSerializerOptions); + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -171,11 +187,8 @@ public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentA /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { - if (grandparentAnimal.PetType == null) - throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); - writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index 0f313e776a4c..4b3fca9fef5c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -218,7 +218,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl { writer.WriteStartObject(); - WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions); + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HealthCheckResult.cs index 3e9090daf3ad..cff257a9cb59 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR { writer.WriteStartObject(); - WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions); + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { if (healthCheckResult.NullableMessageOption.IsSet) if (healthCheckResult.NullableMessageOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index a4015cfa38fe..fdc2bd927d08 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri { writer.WriteStartObject(); - WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions); + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -173,7 +173,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs index 526f27528ec8..e188a49d3f55 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, list, jsonSerializerOptions); + WriteProperties(writer, list, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs index 843719eba586..5fa485012919 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri { writer.WriteStartObject(); - WriteProperties(ref writer, literalStringClass, jsonSerializerOptions); + WriteProperties(writer, literalStringClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -188,7 +188,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs index 90d85e3d306a..15c63b5d7850 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs @@ -36,11 +36,9 @@ public partial class Mammal : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Whale whale, string className) + public Mammal(Whale whale) { Whale = whale; - ClassName = className; OnCreated(); } @@ -48,11 +46,9 @@ public Mammal(Whale whale, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Zebra zebra, string className) + public Mammal(Zebra zebra) { Zebra = zebra; - ClassName = className; OnCreated(); } @@ -60,11 +56,9 @@ public Mammal(Zebra zebra, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Pig pig, string className) + public Mammal(Pig pig) { Pig = pig; - ClassName = className; OnCreated(); } @@ -85,12 +79,6 @@ public Mammal(Pig pig, string className) /// public Pig? Pig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -105,7 +93,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -226,13 +213,13 @@ public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className.Value!); + return new Mammal(pig); if (whale != null) - return new Mammal(whale, className.Value!); + return new Mammal(whale); if (zebra != null) - return new Mammal(zebra, className.Value!); + return new Mammal(zebra); throw new JsonException(); } @@ -250,20 +237,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO if (mammal.Whale != null) { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); - whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } if (mammal.Zebra != null) { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); - zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } if (mammal.Pig != null) { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); - pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } - WriteProperties(ref writer, mammal, jsonSerializerOptions); + WriteProperties(writer, mammal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -274,12 +261,9 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { - if (mammal.ClassName == null) - throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); - writer.WriteString("className", mammal.ClassName); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs index ee394fb6e8fc..ce7434b68fa5 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs @@ -293,7 +293,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, mapTest, jsonSerializerOptions); + WriteProperties(writer, mapTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -304,7 +304,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 900f6c894793..f91b244db083 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -239,7 +239,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -250,7 +250,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs index 00b3de337adb..de2a2d525d23 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo { writer.WriteStartObject(); - WriteProperties(ref writer, model200Response, jsonSerializerOptions); + WriteProperties(writer, model200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs index 745e34d1bde6..fd3eb29a78f2 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, modelClient, jsonSerializerOptions); + WriteProperties(writer, modelClient, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs index 48d338a98d98..2ded0896855d 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs @@ -263,7 +263,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, name, jsonSerializerOptions); + WriteProperties(writer, name, jsonSerializerOptions); writer.WriteEndObject(); } @@ -274,7 +274,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index 41e83711cd41..c74bf13f6d08 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R { writer.WriteStartObject(); - WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); writer.WriteEndObject(); } @@ -182,7 +182,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs index bdfbba4e53a5..ab7911eb6cfc 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs @@ -398,7 +398,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, nullableClass, jsonSerializerOptions); + WriteProperties(writer, nullableClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -409,7 +409,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableGuidClass.cs index 80bbe636918b..d037c1a335c9 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -153,7 +153,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid { writer.WriteStartObject(); - WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions); + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { if (nullableGuidClass.UuidOption.IsSet) if (nullableGuidClass.UuidOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs index 75c5f9087276..db1d9df81024 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs @@ -36,11 +36,9 @@ public partial class NullableShape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Triangle triangle, string shapeType) + public NullableShape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -48,11 +46,9 @@ public NullableShape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Quadrilateral quadrilateral, string shapeType) + public NullableShape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -68,12 +64,6 @@ public NullableShape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -88,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -203,10 +192,10 @@ public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType.Value!); + return new NullableShape(quadrilateral); if (triangle != null) - return new NullableShape(triangle, shapeType.Value!); + return new NullableShape(triangle); throw new JsonException(); } @@ -224,15 +213,15 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J if (nullableShape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } if (nullableShape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, nullableShape, jsonSerializerOptions); + WriteProperties(writer, nullableShape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -243,12 +232,9 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { - if (nullableShape.ShapeType == null) - throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); - writer.WriteString("shapeType", nullableShape.ShapeType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs index bac081f77f34..7bd636d82891 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, numberOnly, jsonSerializerOptions); + WriteProperties(writer, numberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + 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/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index d19c11d0177d..38f7842d5611 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj { writer.WriteStartObject(); - WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions); + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,7 +240,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OneOfString.cs index a4772470b488..fd4bc86610dc 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OneOfString.cs @@ -141,7 +141,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, oneOfString, jsonSerializerOptions); + WriteProperties(writer, oneOfString, jsonSerializerOptions); writer.WriteEndObject(); } @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs index 21135ede6dc2..56e17adb08dd 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs @@ -364,7 +364,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, order, jsonSerializerOptions); + WriteProperties(writer, order, jsonSerializerOptions); writer.WriteEndObject(); } @@ -375,7 +375,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { if (order.CompleteOption.IsSet) writer.WriteBoolean("complete", order.CompleteOption.Value!.Value); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs index 50ab7ea2e0b3..0fbfdb545777 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -202,7 +202,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, { writer.WriteStartObject(); - WriteProperties(ref writer, outerComposite, jsonSerializerOptions); + WriteProperties(writer, outerComposite, jsonSerializerOptions); writer.WriteEndObject(); } @@ -213,7 +213,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ParentPet.cs index 2e56fefaa93a..fe5dc7e87a57 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ParentPet.cs @@ -35,15 +35,21 @@ public partial class ParentPet : GrandparentAnimal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public ParentPet(string petType) : base(petType) + 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 /// @@ -82,6 +88,11 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon 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) @@ -112,7 +123,7 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); - return new ParentPet(petType.Value!); + return new ParentPet(); } /// @@ -124,9 +135,14 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon /// public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + writer.WriteStartObject(); - WriteProperties(ref writer, parentPet, jsonSerializerOptions); + WriteProperties(writer, parentPet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -137,11 +153,8 @@ public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { - if (parentPet.PetType == null) - throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); - writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs index 453564c6d086..59d976894915 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs @@ -350,7 +350,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, pet, jsonSerializerOptions); + WriteProperties(writer, pet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -361,7 +361,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs index 19807191bd63..88ffcca10048 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs @@ -36,11 +36,9 @@ public partial class Pig : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Pig(BasquePig basquePig, string className) + public Pig(BasquePig basquePig) { BasquePig = basquePig; - ClassName = className; OnCreated(); } @@ -48,11 +46,9 @@ public Pig(BasquePig basquePig, string className) /// Initializes a new instance of the class. /// /// - /// className - public Pig(DanishPig danishPig, string className) + public Pig(DanishPig danishPig) { DanishPig = danishPig; - ClassName = className; OnCreated(); } @@ -68,12 +64,6 @@ public Pig(DanishPig danishPig, string className) /// public DanishPig? DanishPig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -88,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -203,10 +192,10 @@ public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className.Value!); + return new Pig(basquePig); if (danishPig != null) - return new Pig(danishPig, className.Value!); + return new Pig(danishPig); throw new JsonException(); } @@ -224,15 +213,15 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions if (pig.BasquePig != null) { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); - basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } if (pig.DanishPig != null) { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); - danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } - WriteProperties(ref writer, pig, jsonSerializerOptions); + WriteProperties(writer, pig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -243,12 +232,9 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { - if (pig.ClassName == null) - throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); - writer.WriteString("className", pig.ClassName); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 312cf0b81db7..d61a3a669217 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi { writer.WriteStartObject(); - WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions); + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); writer.WriteEndObject(); } @@ -234,7 +234,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs index fc2768994114..21f614134e69 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -36,11 +36,9 @@ public partial class Quadrilateral : IValidatableObject /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType) + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { SimpleQuadrilateral = simpleQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -48,11 +46,9 @@ public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilater /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType) + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { ComplexQuadrilateral = complexQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -68,12 +64,6 @@ public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilat /// public ComplexQuadrilateral? ComplexQuadrilateral { get; set; } - /// - /// Gets or Sets QuadrilateralType - /// - [JsonPropertyName("quadrilateralType")] - public string QuadrilateralType { get; set; } - /// /// Gets or Sets additional properties /// @@ -88,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -203,10 +192,10 @@ public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value!); + return new Quadrilateral(complexQuadrilateral); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value!); + return new Quadrilateral(simpleQuadrilateral); throw new JsonException(); } @@ -224,15 +213,15 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J if (quadrilateral.SimpleQuadrilateral != null) { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); - simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } if (quadrilateral.ComplexQuadrilateral != null) { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); - complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, quadrilateral, jsonSerializerOptions); + WriteProperties(writer, quadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -243,12 +232,9 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { - if (quadrilateral.QuadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); - writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 9060c3f6ce7a..31c5940d678d 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril { writer.WriteStartObject(); - WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions); + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index 0e2be679b481..8bd857e66156 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -215,7 +215,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J { writer.WriteStartObject(); - WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions); + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); writer.WriteEndObject(); } @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs index f5fa48c7c77a..12561bdb68c3 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -2159,7 +2159,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + WriteProperties(writer, requiredClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -2170,7 +2170,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs index 7ae873100853..9a55385c9e0a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs @@ -213,7 +213,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ { writer.WriteStartObject(); - WriteProperties(ref writer, varReturn, jsonSerializerOptions); + WriteProperties(writer, varReturn, jsonSerializerOptions); writer.WriteEndObject(); } @@ -224,7 +224,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 19d3d828704c..ea51c6918369 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); writer.WriteEndObject(); } @@ -190,7 +190,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index 82143e553f44..77edc76a3bd3 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 4a3599d1329c..907253b6f63c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl { writer.WriteStartObject(); - WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions); + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs index cd2940a87fe4..329de390e644 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs @@ -36,11 +36,9 @@ public partial class Shape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Triangle triangle, string shapeType) + public Shape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -48,11 +46,9 @@ public Shape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Quadrilateral quadrilateral, string shapeType) + public Shape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -68,12 +64,6 @@ public Shape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -88,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -203,10 +192,10 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType.Value!); + return new Shape(quadrilateral); if (triangle != null) - return new Shape(triangle, shapeType.Value!); + return new Shape(triangle); throw new JsonException(); } @@ -224,15 +213,15 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt if (shape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } if (shape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shape, jsonSerializerOptions); + WriteProperties(writer, shape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -243,12 +232,9 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { - if (shape.ShapeType == null) - throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); - writer.WriteString("shapeType", shape.ShapeType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs index d540276b6045..d7f2f03ff8f3 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, { writer.WriteStartObject(); - WriteProperties(ref writer, shapeInterface, jsonSerializerOptions); + WriteProperties(writer, shapeInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs index d0d068c80980..01c4ee1e1ee2 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -36,11 +36,9 @@ public partial class ShapeOrNull : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Triangle triangle, string shapeType) + public ShapeOrNull(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -48,11 +46,9 @@ public ShapeOrNull(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) + public ShapeOrNull(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -68,12 +64,6 @@ public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral? Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -88,7 +78,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -203,10 +192,10 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType.Value!); + return new ShapeOrNull(quadrilateral); if (triangle != null) - return new ShapeOrNull(triangle, shapeType.Value!); + return new ShapeOrNull(triangle); throw new JsonException(); } @@ -224,15 +213,15 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS if (shapeOrNull.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } if (shapeOrNull.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions); + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); writer.WriteEndObject(); } @@ -243,12 +232,9 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { - if (shapeOrNull.ShapeType == null) - throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); - writer.WriteString("shapeType", shapeOrNull.ShapeType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index a9292a0bd66e..e90f8b8b6198 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad { writer.WriteStartObject(); - WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs index 76a8b8e6dc5c..4d1c36200905 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN { writer.WriteStartObject(); - WriteProperties(ref writer, specialModelName, jsonSerializerOptions); + WriteProperties(writer, specialModelName, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs index 55102aa3e897..43fe662b51cf 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs @@ -178,7 +178,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, tag, jsonSerializerOptions); + WriteProperties(writer, tag, jsonSerializerOptions); writer.WriteEndObject(); } @@ -189,7 +189,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index 3ddea72fbbba..323771bb32fe 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 75432585a5f2..a854b4855ce2 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -155,7 +155,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index 998c873580ec..b95a98826572 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -154,7 +154,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs index 01d0b9cc379f..b450383d3357 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs @@ -36,11 +36,9 @@ public partial class Triangle : IValidatableObject /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) + public Triangle(EquilateralTriangle equilateralTriangle) { EquilateralTriangle = equilateralTriangle; - TriangleType = triangleType; OnCreated(); } @@ -48,11 +46,9 @@ public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) + public Triangle(IsoscelesTriangle isoscelesTriangle) { IsoscelesTriangle = isoscelesTriangle; - TriangleType = triangleType; OnCreated(); } @@ -60,11 +56,9 @@ public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) + public Triangle(ScaleneTriangle scaleneTriangle) { ScaleneTriangle = scaleneTriangle; - TriangleType = triangleType; OnCreated(); } @@ -85,12 +79,6 @@ public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) /// public ScaleneTriangle? ScaleneTriangle { get; set; } - /// - /// Gets or Sets TriangleType - /// - [JsonPropertyName("triangleType")] - public string TriangleType { get; set; } - /// /// Gets or Sets additional properties /// @@ -105,7 +93,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -226,13 +213,13 @@ public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType.Value!); + return new Triangle(equilateralTriangle); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType.Value!); + return new Triangle(isoscelesTriangle); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType.Value!); + return new Triangle(scaleneTriangle); throw new JsonException(); } @@ -250,20 +237,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali if (triangle.EquilateralTriangle != null) { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); - equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } if (triangle.IsoscelesTriangle != null) { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); - isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } if (triangle.ScaleneTriangle != null) { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); - scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } - WriteProperties(ref writer, triangle, jsonSerializerOptions); + WriteProperties(writer, triangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -274,12 +261,9 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { - if (triangle.TriangleType == null) - throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); - writer.WriteString("triangleType", triangle.TriangleType); } } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs index 788fe0022f5f..d88f6c5af418 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte { writer.WriteStartObject(); - WriteProperties(ref writer, triangleInterface, jsonSerializerOptions); + WriteProperties(writer, triangleInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs index 8268921fab54..018dfd665219 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs @@ -409,7 +409,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, user, jsonSerializerOptions); + WriteProperties(writer, user, jsonSerializerOptions); writer.WriteEndObject(); } @@ -420,7 +420,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs index a857b4148756..0e794d7a1a68 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs @@ -198,7 +198,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, whale, jsonSerializerOptions); + WriteProperties(writer, whale, jsonSerializerOptions); writer.WriteEndObject(); } @@ -209,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs index f7bfa4def636..d481b0386d85 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs @@ -255,7 +255,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, zebra, jsonSerializerOptions); + WriteProperties(writer, zebra, jsonSerializerOptions); writer.WriteEndObject(); } @@ -266,7 +266,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 1e5374cfd8a3..f108e118e0fb 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -222,7 +222,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn { writer.WriteStartObject(); - WriteProperties(ref writer, zeroBasedEnumClass, jsonSerializerOptions); + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -233,7 +233,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + 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/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs index 713da49169c4..cddef3bb9329 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -251,6 +251,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs index 0492da71e173..00986383cd24 100644 --- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs +++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res { writer.WriteStartObject(); - WriteProperties(ref writer, nowGet200Response, jsonSerializerOptions); + WriteProperties(writer, nowGet200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -191,7 +191,7 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions) { if (nowGet200Response.NowOption.IsSet) writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat)); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 32d8880e04e3..572d306ed52f 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -362,6 +362,43 @@ public static bool IsJsonMime(string mime) 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 /// diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs index c7ae164f09bf..2e4d5cb3bb8f 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Activity.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, activity, jsonSerializerOptions); + WriteProperties(writer, activity, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs index ae0dd075bf6e..b24ba8678984 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent { writer.WriteStartObject(); - WriteProperties(ref writer, activityOutputElementRepresentation, jsonSerializerOptions); + WriteProperties(writer, activityOutputElementRepresentation, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs index 322f3e966424..dcc268fc3a8d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs @@ -318,7 +318,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi { writer.WriteStartObject(); - WriteProperties(ref writer, additionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, additionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -329,7 +329,7 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs index 8684723f4522..29362b0ca361 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Animal.cs @@ -32,12 +32,10 @@ public partial class Animal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") [JsonConstructor] - public Animal(string className, Option color = default) + public Animal(Option color = default) { - ClassName = className; ColorOption = color; OnCreated(); } @@ -45,10 +43,11 @@ public Animal(string className, Option color = default) partial void OnCreated(); /// - /// Gets or Sets ClassName + /// The discriminator /// - [JsonPropertyName("className")] - public string ClassName { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string ClassName { get; } = "Animal"; /// /// Used to track the state of Color @@ -77,7 +76,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Animal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" Color: ").Append(Color).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); @@ -130,6 +128,14 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver 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) @@ -166,7 +172,7 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal."); - return new Animal(className.Value, color); + return new Animal(color); } /// @@ -178,9 +184,19 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver /// 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(ref writer, animal, jsonSerializerOptions); + WriteProperties(writer, animal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -191,11 +207,8 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions) { - if (animal.ClassName == null) - throw new ArgumentNullException(nameof(animal.ClassName), "Property is required for class Animal."); - if (animal.ColorOption.IsSet && animal.Color == null) throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs index 682dd4051a7d..f63a202f3973 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -198,7 +198,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, apiResponse, jsonSerializerOptions); + WriteProperties(writer, apiResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -209,7 +209,7 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs index 0dfab1dc96a2..87e58a000210 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Apple.cs @@ -227,7 +227,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, apple, jsonSerializerOptions); + WriteProperties(writer, apple, jsonSerializerOptions); writer.WriteEndObject(); } @@ -238,7 +238,7 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs index eea4a2f9c046..6a2e8b75f6da 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/AppleReq.cs @@ -164,7 +164,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, appleReq, jsonSerializerOptions); + WriteProperties(writer, appleReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, AppleReq appleReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, AppleReq appleReq, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs index ed7268fe4e5e..d66d69222da8 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfArrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs index 815ec9d64641..7ec6a05f2420 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe { writer.WriteStartObject(); - WriteProperties(ref writer, arrayOfNumberOnly, jsonSerializerOptions); + WriteProperties(writer, arrayOfNumberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs index c2a33b41467d..0ae28dc07d59 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ArrayTest.cs @@ -200,7 +200,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, arrayTest, jsonSerializerOptions); + WriteProperties(writer, arrayTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -211,7 +211,7 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs index 0129ad28b14a..f8f25778428e 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Banana.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO { writer.WriteStartObject(); - WriteProperties(ref writer, banana, jsonSerializerOptions); + WriteProperties(writer, banana, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions) + 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/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs index 8b011a03348a..848e8164b4ac 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BananaReq.cs @@ -165,7 +165,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, bananaReq, jsonSerializerOptions); + WriteProperties(writer, bananaReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSerializerOptions jsonSerializerOptions) { writer.WriteNumber("lengthCm", bananaReq.LengthCm); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs index 53c20a25cd10..863cc82bc782 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/BasquePig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, basquePig, jsonSerializerOptions); + WriteProperties(writer, basquePig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, BasquePig basquePig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, BasquePig basquePig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs index d2ef72a6aa50..f24497e3ad68 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Capitalization.cs @@ -267,7 +267,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, { writer.WriteStartObject(); - WriteProperties(ref writer, capitalization, jsonSerializerOptions); + WriteProperties(writer, capitalization, jsonSerializerOptions); writer.WriteEndObject(); } @@ -278,7 +278,7 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs index 9314e3211324..d11d16c855e0 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Cat.cs @@ -32,11 +32,10 @@ public partial class Cat : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// color (default to "red") /// declawed [JsonConstructor] - public Cat(string className, Option color = default, Option declawed = default) : base(className, color) + public Cat(Option color = default, Option declawed = default) : base(color) { DeclawedOption = declawed; OnCreated(); @@ -44,6 +43,13 @@ public Cat(string className, Option color = default, Option decla 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 /// @@ -141,7 +147,7 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (declawed.IsSet && declawed.Value == null) throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat."); - return new Cat(className.Value, color, declawed); + return new Cat(color, declawed); } /// @@ -155,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, cat, jsonSerializerOptions); + WriteProperties(writer, cat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -166,11 +172,8 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions) { - if (cat.ClassName == null) - throw new ArgumentNullException(nameof(cat.ClassName), "Property is required for class Cat."); - if (cat.ColorOption.IsSet && cat.Color == null) throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs index 79755fde4999..667e094c6ff4 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Category.cs @@ -171,7 +171,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, category, jsonSerializerOptions); + WriteProperties(writer, category, jsonSerializerOptions); writer.WriteEndObject(); } @@ -182,7 +182,7 @@ public override void Write(Utf8JsonWriter writer, Category category, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Category category, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs index 8b96dc29f79a..a27854474976 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ChildCat.cs @@ -33,12 +33,10 @@ public partial class ChildCat : ParentPet, IValidatableObject /// Initializes a new instance of the class. /// /// name - /// petType (default to PetTypeEnum.ChildCat) [JsonConstructor] - public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType)) + public ChildCat(Option name = default) : base() { NameOption = name; - PetType = petType; OnCreated(); } @@ -96,12 +94,6 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) throw new NotImplementedException($"Value could not be handled: '{value}'"); } - /// - /// Gets or Sets PetType - /// - [JsonPropertyName("pet_type")] - public new PetTypeEnum PetType { get; set; } - /// /// Used to track the state of Name /// @@ -115,6 +107,13 @@ public static string PetTypeEnumToJsonValue(PetTypeEnum value) [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 /// @@ -125,7 +124,6 @@ public override string ToString() sb.Append("class ChildCat {\n"); sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -194,7 +192,7 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat."); - return new ChildCat(name, petType.Value.Value); + return new ChildCat(name); } /// @@ -208,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, childCat, jsonSerializerOptions); + WriteProperties(writer, childCat, jsonSerializerOptions); writer.WriteEndObject(); } @@ -219,7 +217,7 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions) + 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."); @@ -227,8 +225,7 @@ public void WriteProperties(ref Utf8JsonWriter writer, ChildCat childCat, JsonSe if (childCat.NameOption.IsSet) writer.WriteString("name", childCat.Name); - var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType); - writer.WriteString("pet_type", petTypeRawValue); + writer.WriteString("pet_type", ChildCat.PetTypeEnumToJsonValue(childCat.PetType)); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs index f7fb43c7d1f9..9e254109cfcb 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ClassModel.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, classModel, jsonSerializerOptions); + WriteProperties(writer, classModel, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs index 747b36ec65bd..1a42f967ca91 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu { writer.WriteStartObject(); - WriteProperties(ref writer, complexQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, complexQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ComplexQuadrilateral complexQu /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ComplexQuadrilateral complexQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs index c28634e4e13e..9eb8b733358d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DanishPig.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria { writer.WriteStartObject(); - WriteProperties(ref writer, danishPig, jsonSerializerOptions); + WriteProperties(writer, danishPig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DanishPig danishPig, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DanishPig danishPig, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs index 1f7034885915..c82942faae75 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, dateOnlyClass, jsonSerializerOptions); + WriteProperties(writer, dateOnlyClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + 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/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs index a87e900dab45..064985cce436 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/DeprecatedObject.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj { writer.WriteStartObject(); - WriteProperties(ref writer, deprecatedObject, jsonSerializerOptions); + WriteProperties(writer, deprecatedObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs index 98de62908b30..75a60416f90c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Dog.cs @@ -32,11 +32,10 @@ public partial class Dog : Animal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// className /// breed /// color (default to "red") [JsonConstructor] - public Dog(string className, Option breed = default, Option color = default) : base(className, color) + public Dog(Option breed = default, Option color = default) : base(color) { BreedOption = breed; OnCreated(); @@ -44,6 +43,13 @@ public Dog(string className, Option breed = default, Option colo 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 /// @@ -140,7 +146,7 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, if (color.IsSet && color.Value == null) throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog."); - return new Dog(className.Value, breed, color); + return new Dog(breed, color); } /// @@ -154,7 +160,7 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, dog, jsonSerializerOptions); + WriteProperties(writer, dog, jsonSerializerOptions); writer.WriteEndObject(); } @@ -165,11 +171,8 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions) { - if (dog.ClassName == null) - throw new ArgumentNullException(nameof(dog.ClassName), "Property is required for class Dog."); - if (dog.BreedOption.IsSet && dog.Breed == null) throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs index 47d270018271..13fe9ec2c1a5 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Drawing.cs @@ -218,7 +218,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, drawing, jsonSerializerOptions); + WriteProperties(writer, drawing, jsonSerializerOptions); writer.WriteEndObject(); } @@ -229,7 +229,7 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs index 0c4d4f2605bb..a0b7504e9d2e 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -309,7 +309,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, enumArrays, jsonSerializerOptions); + WriteProperties(writer, enumArrays, jsonSerializerOptions); writer.WriteEndObject(); } @@ -320,7 +320,7 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs index a49eb0130a41..dc39f92290d6 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EnumTest.cs @@ -827,7 +827,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, enumTest, jsonSerializerOptions); + WriteProperties(writer, enumTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -838,7 +838,7 @@ public override void Write(Utf8JsonWriter writer, EnumTest enumTest, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions) { var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired); writer.WriteString("enum_string_required", enumStringRequiredRawValue); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs index bbf4bf8f8e09..b84f89b531dc 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EquilateralTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera { writer.WriteStartObject(); - WriteProperties(ref writer, equilateralTriangle, jsonSerializerOptions); + WriteProperties(writer, equilateralTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, EquilateralTriangle equilatera /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, EquilateralTriangle equilateralTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs index b59035ea73a2..95403fdaf96d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/File.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, file, jsonSerializerOptions); + WriteProperties(writer, file, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs index a4afe164a01b..4906accc7ed4 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema { writer.WriteStartObject(); - WriteProperties(ref writer, fileSchemaTestClass, jsonSerializerOptions); + WriteProperties(writer, fileSchemaTestClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs index 66a5f1546ca5..a78d7a84f34f 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Foo.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, foo, jsonSerializerOptions); + WriteProperties(writer, foo, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs index 56330dc819ad..4564148c4d9c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe { writer.WriteStartObject(); - WriteProperties(ref writer, fooGetDefaultResponse, jsonSerializerOptions); + WriteProperties(writer, fooGetDefaultResponse, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs index 8448947b66fb..09b13bde9f7a 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FormatTest.cs @@ -703,7 +703,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, formatTest, jsonSerializerOptions); + WriteProperties(writer, formatTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -714,7 +714,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FormatTest formatTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs index f466bc94d996..8e650b7b07cc 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Fruit.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, fruit, jsonSerializerOptions); + WriteProperties(writer, fruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs index 03ef926c47d4..f5dd6d56278f 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/FruitReq.cs @@ -169,7 +169,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali { writer.WriteStartObject(); - WriteProperties(ref writer, fruitReq, jsonSerializerOptions); + WriteProperties(writer, fruitReq, jsonSerializerOptions); writer.WriteEndObject(); } @@ -180,7 +180,7 @@ public override void Write(Utf8JsonWriter writer, FruitReq fruitReq, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, FruitReq fruitReq, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs index feb402445612..14d47fa32935 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GmFruit.cs @@ -203,16 +203,16 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize if (gmFruit.AppleOption.IsSet && gmFruit.AppleOption.Value != null) { AppleJsonConverter AppleJsonConverter = (AppleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(gmFruit.AppleOption.Value.GetType())); - AppleJsonConverter.WriteProperties(ref writer, gmFruit.AppleOption.Value, jsonSerializerOptions); + 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(ref writer, gmFruit.BananaOption.Value, jsonSerializerOptions); + BananaJsonConverter.WriteProperties(writer, gmFruit.BananaOption.Value, jsonSerializerOptions); } - WriteProperties(ref writer, gmFruit, jsonSerializerOptions); + WriteProperties(writer, gmFruit, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs index 6b7d7ae8da68..86246ae54570 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/GrandparentAnimal.cs @@ -32,21 +32,20 @@ public partial class GrandparentAnimal : IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public GrandparentAnimal(string petType) + public GrandparentAnimal() { - PetType = petType; OnCreated(); } partial void OnCreated(); /// - /// Gets or Sets PetType + /// The discriminator /// - [JsonPropertyName("pet_type")] - public string PetType { get; set; } + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string PetType { get; } = "GrandparentAnimal"; /// /// Gets or Sets additional properties @@ -62,7 +61,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class GrandparentAnimal {\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -113,6 +111,14 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t 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) @@ -143,7 +149,7 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class GrandparentAnimal."); - return new GrandparentAnimal(petType.Value); + return new GrandparentAnimal(); } /// @@ -155,9 +161,19 @@ public override GrandparentAnimal Read(ref Utf8JsonReader utf8JsonReader, Type t /// 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(ref writer, grandparentAnimal, jsonSerializerOptions); + WriteProperties(writer, grandparentAnimal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -168,11 +184,8 @@ public override void Write(Utf8JsonWriter writer, GrandparentAnimal grandparentA /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, GrandparentAnimal grandparentAnimal, JsonSerializerOptions jsonSerializerOptions) { - if (grandparentAnimal.PetType == null) - throw new ArgumentNullException(nameof(grandparentAnimal.PetType), "Property is required for class GrandparentAnimal."); - writer.WriteString("pet_type", grandparentAnimal.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs index a58bd7569681..88c5d4274eab 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs @@ -215,7 +215,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl { writer.WriteStartObject(); - WriteProperties(ref writer, hasOnlyReadOnly, jsonSerializerOptions); + WriteProperties(writer, hasOnlyReadOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs index b312de2727ca..4f9c831edc26 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/HealthCheckResult.cs @@ -148,7 +148,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR { writer.WriteStartObject(); - WriteProperties(ref writer, healthCheckResult, jsonSerializerOptions); + WriteProperties(writer, healthCheckResult, jsonSerializerOptions); writer.WriteEndObject(); } @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, HealthCheckResult healthCheckR /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, HealthCheckResult healthCheckResult, JsonSerializerOptions jsonSerializerOptions) { if (healthCheckResult.NullableMessageOption.IsSet) if (healthCheckResult.NullableMessageOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs index 3f4aa3229c4e..384e48f3a155 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/IsoscelesTriangle.cs @@ -159,7 +159,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri { writer.WriteStartObject(); - WriteProperties(ref writer, isoscelesTriangle, jsonSerializerOptions); + WriteProperties(writer, isoscelesTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -170,7 +170,7 @@ public override void Write(Utf8JsonWriter writer, IsoscelesTriangle isoscelesTri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, IsoscelesTriangle isoscelesTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs index 2e0e16258a90..07fcd017a689 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/List.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, list, jsonSerializerOptions); + WriteProperties(writer, list, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs index be67dd4da8c0..c5fc2e2e77c1 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/LiteralStringClass.cs @@ -174,7 +174,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri { writer.WriteStartObject(); - WriteProperties(ref writer, literalStringClass, jsonSerializerOptions); + WriteProperties(writer, literalStringClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -185,7 +185,7 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 05e439a9c3e6..1be5661d9936 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -33,11 +33,9 @@ public partial class Mammal : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Whale whale, string className) + public Mammal(Whale whale) { Whale = whale; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Mammal(Whale whale, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Zebra zebra, string className) + public Mammal(Zebra zebra) { Zebra = zebra; - ClassName = className; OnCreated(); } @@ -57,11 +53,9 @@ public Mammal(Zebra zebra, string className) /// Initializes a new instance of the class. /// /// - /// className - public Mammal(Pig pig, string className) + public Mammal(Pig pig) { Pig = pig; - ClassName = className; OnCreated(); } @@ -82,12 +76,6 @@ public Mammal(Pig pig, string className) /// public Pig Pig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Mammal {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Mammal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver throw new ArgumentNullException(nameof(className), "Property is not nullable for class Mammal."); if (pig != null) - return new Mammal(pig, className.Value); + return new Mammal(pig); if (whale != null) - return new Mammal(whale, className.Value); + return new Mammal(whale); if (zebra != null) - return new Mammal(zebra, className.Value); + return new Mammal(zebra); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO if (mammal.Whale != null) { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); - whaleJsonConverter.WriteProperties(ref writer, mammal.Whale, jsonSerializerOptions); + whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } if (mammal.Zebra != null) { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); - zebraJsonConverter.WriteProperties(ref writer, mammal.Zebra, jsonSerializerOptions); + zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } if (mammal.Pig != null) { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); - pigJsonConverter.WriteProperties(ref writer, mammal.Pig, jsonSerializerOptions); + pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } - WriteProperties(ref writer, mammal, jsonSerializerOptions); + WriteProperties(writer, mammal, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Mammal mammal, JsonSerializerOptions jsonSerializerOptions) { - if (mammal.ClassName == null) - throw new ArgumentNullException(nameof(mammal.ClassName), "Property is required for class Mammal."); - writer.WriteString("className", mammal.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs index 39b904e1681c..6be561e42f14 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MapTest.cs @@ -290,7 +290,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize { writer.WriteStartObject(); - WriteProperties(ref writer, mapTest, jsonSerializerOptions); + WriteProperties(writer, mapTest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -301,7 +301,7 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index c2ff988661c4..095c00f45621 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -236,7 +236,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); + WriteProperties(writer, mixedPropertiesAndAdditionalPropertiesClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -247,7 +247,7 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs index c6c6c408e8f0..8c0a59ace8bd 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Model200Response.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo { writer.WriteStartObject(); - WriteProperties(ref writer, model200Response, jsonSerializerOptions); + WriteProperties(writer, model200Response, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs index 90209abbdfa3..e8cca355d288 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ModelClient.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, modelClient, jsonSerializerOptions); + WriteProperties(writer, modelClient, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs index c736546e3e0c..90a80bda8815 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Name.cs @@ -260,7 +260,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, name, jsonSerializerOptions); + WriteProperties(writer, name, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,7 +271,7 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs index cd1516104e35..d10268f2927a 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NotificationtestGetElementsV1ResponseMPayload.cs @@ -168,7 +168,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R { writer.WriteStartObject(); - WriteProperties(ref writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); + WriteProperties(writer, notificationtestGetElementsV1ResponseMPayload, jsonSerializerOptions); writer.WriteEndObject(); } @@ -179,7 +179,7 @@ public override void Write(Utf8JsonWriter writer, NotificationtestGetElementsV1R /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NotificationtestGetElementsV1ResponseMPayload notificationtestGetElementsV1ResponseMPayload, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs index 9cbc709be9a2..f844fec808c5 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableClass.cs @@ -395,7 +395,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, nullableClass, jsonSerializerOptions); + WriteProperties(writer, nullableClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs index 0b88d5dbe20b..ef86eb595aca 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableGuidClass.cs @@ -150,7 +150,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid { writer.WriteStartObject(); - WriteProperties(ref writer, nullableGuidClass, jsonSerializerOptions); + WriteProperties(writer, nullableGuidClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -161,7 +161,7 @@ public override void Write(Utf8JsonWriter writer, NullableGuidClass nullableGuid /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableGuidClass nullableGuidClass, JsonSerializerOptions jsonSerializerOptions) { if (nullableGuidClass.UuidOption.IsSet) if (nullableGuidClass.UuidOption.Value != null) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index d66595994262..10061a2c228b 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -33,11 +33,9 @@ public partial class NullableShape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Triangle triangle, string shapeType) + public NullableShape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public NullableShape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public NullableShape(Quadrilateral quadrilateral, string shapeType) + public NullableShape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public NullableShape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class NullableShape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override NullableShape Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class NullableShape."); if (quadrilateral != null) - return new NullableShape(quadrilateral, shapeType.Value); + return new NullableShape(quadrilateral); if (triangle != null) - return new NullableShape(triangle, shapeType.Value); + return new NullableShape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J if (nullableShape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, nullableShape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } if (nullableShape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, nullableShape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, nullableShape, jsonSerializerOptions); + WriteProperties(writer, nullableShape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, NullableShape nullableShape, JsonSerializerOptions jsonSerializerOptions) { - if (nullableShape.ShapeType == null) - throw new ArgumentNullException(nameof(nullableShape.ShapeType), "Property is required for class NullableShape."); - writer.WriteString("shapeType", nullableShape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs index cf2291059d02..2b602ec80d78 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer { writer.WriteStartObject(); - WriteProperties(ref writer, numberOnly, jsonSerializerOptions); + WriteProperties(writer, numberOnly, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions) + 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/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index aa52b39b2dae..5cc97e836da0 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -226,7 +226,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj { writer.WriteStartObject(); - WriteProperties(ref writer, objectWithDeprecatedFields, jsonSerializerOptions); + WriteProperties(writer, objectWithDeprecatedFields, jsonSerializerOptions); writer.WriteEndObject(); } @@ -237,7 +237,7 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs index 258453564b0b..0f4f13f311b0 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OneOfString.cs @@ -138,7 +138,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS { writer.WriteStartObject(); - WriteProperties(ref writer, oneOfString, jsonSerializerOptions); + WriteProperties(writer, oneOfString, jsonSerializerOptions); writer.WriteEndObject(); } @@ -149,7 +149,7 @@ public override void Write(Utf8JsonWriter writer, OneOfString oneOfString, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, OneOfString oneOfString, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs index ee06c7a739c9..8d0ff1212132 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Order.cs @@ -361,7 +361,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, order, jsonSerializerOptions); + WriteProperties(writer, order, jsonSerializerOptions); writer.WriteEndObject(); } @@ -372,7 +372,7 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions) { if (order.CompleteOption.IsSet) writer.WriteBoolean("complete", order.CompleteOption.Value.Value); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs index a520b16a5967..bb1af3218659 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -199,7 +199,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, { writer.WriteStartObject(); - WriteProperties(ref writer, outerComposite, jsonSerializerOptions); + WriteProperties(writer, outerComposite, jsonSerializerOptions); writer.WriteEndObject(); } @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs index c451e1a8991b..5d1cab769fa8 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ParentPet.cs @@ -32,15 +32,21 @@ public partial class ParentPet : GrandparentAnimal, IValidatableObject /// /// Initializes a new instance of the class. /// - /// petType [JsonConstructor] - public ParentPet(string petType) : base(petType) + 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 /// @@ -79,6 +85,11 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon 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) @@ -109,7 +120,7 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon if (petType.IsSet && petType.Value == null) throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ParentPet."); - return new ParentPet(petType.Value); + return new ParentPet(); } /// @@ -121,9 +132,14 @@ public override ParentPet Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon /// public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { + if (parentPet is ChildCat childCat){ + JsonSerializer.Serialize(writer, childCat, jsonSerializerOptions); + return; + } + writer.WriteStartObject(); - WriteProperties(ref writer, parentPet, jsonSerializerOptions); + WriteProperties(writer, parentPet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -134,11 +150,8 @@ public override void Write(Utf8JsonWriter writer, ParentPet parentPet, JsonSeria /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ParentPet parentPet, JsonSerializerOptions jsonSerializerOptions) { - if (parentPet.PetType == null) - throw new ArgumentNullException(nameof(parentPet.PetType), "Property is required for class ParentPet."); - writer.WriteString("pet_type", parentPet.PetType); } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs index a106a05b2f4d..ec63640215f3 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pet.cs @@ -347,7 +347,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, pet, jsonSerializerOptions); + WriteProperties(writer, pet, jsonSerializerOptions); writer.WriteEndObject(); } @@ -358,7 +358,7 @@ public override void Write(Utf8JsonWriter writer, Pet pet, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pet pet, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs index d3bbeb8ff326..19e395f1de47 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -33,11 +33,9 @@ public partial class Pig : IValidatableObject /// Initializes a new instance of the class. /// /// - /// className - public Pig(BasquePig basquePig, string className) + public Pig(BasquePig basquePig) { BasquePig = basquePig; - ClassName = className; OnCreated(); } @@ -45,11 +43,9 @@ public Pig(BasquePig basquePig, string className) /// Initializes a new instance of the class. /// /// - /// className - public Pig(DanishPig danishPig, string className) + public Pig(DanishPig danishPig) { DanishPig = danishPig; - ClassName = className; OnCreated(); } @@ -65,12 +61,6 @@ public Pig(DanishPig danishPig, string className) /// public DanishPig DanishPig { get; set; } - /// - /// Gets or Sets ClassName - /// - [JsonPropertyName("className")] - public string ClassName { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Pig {\n"); - sb.Append(" ClassName: ").Append(ClassName).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Pig Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, throw new ArgumentNullException(nameof(className), "Property is not nullable for class Pig."); if (basquePig != null) - return new Pig(basquePig, className.Value); + return new Pig(basquePig); if (danishPig != null) - return new Pig(danishPig, className.Value); + return new Pig(danishPig); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions if (pig.BasquePig != null) { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); - basquePigJsonConverter.WriteProperties(ref writer, pig.BasquePig, jsonSerializerOptions); + basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } if (pig.DanishPig != null) { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); - danishPigJsonConverter.WriteProperties(ref writer, pig.DanishPig, jsonSerializerOptions); + danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } - WriteProperties(ref writer, pig, jsonSerializerOptions); + WriteProperties(writer, pig, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions jsonSerializerOptions) { - if (pig.ClassName == null) - throw new ArgumentNullException(nameof(pig.ClassName), "Property is required for class Pig."); - writer.WriteString("className", pig.ClassName); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 0c176589d063..30edd0b77d2d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -220,7 +220,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi { writer.WriteStartObject(); - WriteProperties(ref writer, polymorphicProperty, jsonSerializerOptions); + WriteProperties(writer, polymorphicProperty, jsonSerializerOptions); writer.WriteEndObject(); } @@ -231,7 +231,7 @@ public override void Write(Utf8JsonWriter writer, PolymorphicProperty polymorphi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, PolymorphicProperty polymorphicProperty, JsonSerializerOptions jsonSerializerOptions) { } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index f3ef21718ae4..3d333d7958fb 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -33,11 +33,9 @@ public partial class Quadrilateral : IValidatableObject /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilateralType) + public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral) { SimpleQuadrilateral = simpleQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -45,11 +43,9 @@ public Quadrilateral(SimpleQuadrilateral simpleQuadrilateral, string quadrilater /// Initializes a new instance of the class. /// /// - /// quadrilateralType - public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilateralType) + public Quadrilateral(ComplexQuadrilateral complexQuadrilateral) { ComplexQuadrilateral = complexQuadrilateral; - QuadrilateralType = quadrilateralType; OnCreated(); } @@ -65,12 +61,6 @@ public Quadrilateral(ComplexQuadrilateral complexQuadrilateral, string quadrilat /// public ComplexQuadrilateral ComplexQuadrilateral { get; set; } - /// - /// Gets or Sets QuadrilateralType - /// - [JsonPropertyName("quadrilateralType")] - public string QuadrilateralType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Quadrilateral {\n"); - sb.Append(" QuadrilateralType: ").Append(QuadrilateralType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Quadrilateral Read(ref Utf8JsonReader utf8JsonReader, Type typeT throw new ArgumentNullException(nameof(quadrilateralType), "Property is not nullable for class Quadrilateral."); if (complexQuadrilateral != null) - return new Quadrilateral(complexQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(complexQuadrilateral); if (simpleQuadrilateral != null) - return new Quadrilateral(simpleQuadrilateral, quadrilateralType.Value); + return new Quadrilateral(simpleQuadrilateral); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J if (quadrilateral.SimpleQuadrilateral != null) { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); - simpleQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); + simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } if (quadrilateral.ComplexQuadrilateral != null) { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); - complexQuadrilateralJsonConverter.WriteProperties(ref writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); + complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, quadrilateral, jsonSerializerOptions); + WriteProperties(writer, quadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Quadrilateral quadrilateral, JsonSerializerOptions jsonSerializerOptions) { - if (quadrilateral.QuadrilateralType == null) - throw new ArgumentNullException(nameof(quadrilateral.QuadrilateralType), "Property is required for class Quadrilateral."); - writer.WriteString("quadrilateralType", quadrilateral.QuadrilateralType); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs index 75b7e516cfca..610005a05408 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/QuadrilateralInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril { writer.WriteStartObject(); - WriteProperties(ref writer, quadrilateralInterface, jsonSerializerOptions); + WriteProperties(writer, quadrilateralInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, QuadrilateralInterface quadril /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, QuadrilateralInterface quadrilateralInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs index c7ee548df4db..87358abb827d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs @@ -212,7 +212,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J { writer.WriteStartObject(); - WriteProperties(ref writer, readOnlyFirst, jsonSerializerOptions); + WriteProperties(writer, readOnlyFirst, jsonSerializerOptions); writer.WriteEndObject(); } @@ -223,7 +223,7 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs index b080aebf5285..dfd9944e15e3 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -2156,7 +2156,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J { writer.WriteStartObject(); - WriteProperties(ref writer, requiredClass, jsonSerializerOptions); + WriteProperties(writer, requiredClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -2167,7 +2167,7 @@ public override void Write(Utf8JsonWriter writer, RequiredClass requiredClass, J /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RequiredClass requiredClass, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs index 3b97b6b6ff25..b294720b3318 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Return.cs @@ -210,7 +210,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ { writer.WriteStartObject(); - WriteProperties(ref writer, varReturn, jsonSerializerOptions); + WriteProperties(writer, varReturn, jsonSerializerOptions); writer.WriteEndObject(); } @@ -221,7 +221,7 @@ public override void Write(Utf8JsonWriter writer, Return varReturn, JsonSerializ /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Return varReturn, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs index 17b1921a0521..494ee791a242 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -176,7 +176,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHash, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHash, jsonSerializerOptions); writer.WriteEndObject(); } @@ -187,7 +187,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs index bc4d2eed98cc..4d0df8c9fc49 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo { writer.WriteStartObject(); - WriteProperties(ref writer, rolesReportsHashRole, jsonSerializerOptions); + WriteProperties(writer, rolesReportsHashRole, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs index 52a8e0d69c60..47081ede38ef 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ScaleneTriangle.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl { writer.WriteStartObject(); - WriteProperties(ref writer, scaleneTriangle, jsonSerializerOptions); + WriteProperties(writer, scaleneTriangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, ScaleneTriangle scaleneTriangl /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ScaleneTriangle scaleneTriangle, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs index ffd95a8fdff1..d4883a363a21 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -33,11 +33,9 @@ public partial class Shape : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Triangle triangle, string shapeType) + public Shape(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public Shape(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public Shape(Quadrilateral quadrilateral, string shapeType) + public Shape(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public Shape(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Shape {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override Shape Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class Shape."); if (quadrilateral != null) - return new Shape(quadrilateral, shapeType.Value); + return new Shape(quadrilateral); if (triangle != null) - return new Shape(triangle, shapeType.Value); + return new Shape(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt if (shape.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shape.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } if (shape.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shape.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shape, jsonSerializerOptions); + WriteProperties(writer, shape, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Shape shape, JsonSerializerOptions jsonSerializerOptions) { - if (shape.ShapeType == null) - throw new ArgumentNullException(nameof(shape.ShapeType), "Property is required for class Shape."); - writer.WriteString("shapeType", shape.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs index 5bd364cc6a41..3027d9142baf 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, { writer.WriteStartObject(); - WriteProperties(ref writer, shapeInterface, jsonSerializerOptions); + WriteProperties(writer, shapeInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, ShapeInterface shapeInterface, /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeInterface shapeInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index d60f396c70da..2d9fb2cbb334 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -33,11 +33,9 @@ public partial class ShapeOrNull : IValidatableObject /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Triangle triangle, string shapeType) + public ShapeOrNull(Triangle triangle) { Triangle = triangle; - ShapeType = shapeType; OnCreated(); } @@ -45,11 +43,9 @@ public ShapeOrNull(Triangle triangle, string shapeType) /// Initializes a new instance of the class. /// /// - /// shapeType - public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) + public ShapeOrNull(Quadrilateral quadrilateral) { Quadrilateral = quadrilateral; - ShapeType = shapeType; OnCreated(); } @@ -65,12 +61,6 @@ public ShapeOrNull(Quadrilateral quadrilateral, string shapeType) /// public Quadrilateral Quadrilateral { get; set; } - /// - /// Gets or Sets ShapeType - /// - [JsonPropertyName("shapeType")] - public string ShapeType { get; set; } - /// /// Gets or Sets additional properties /// @@ -85,7 +75,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ShapeOrNull {\n"); - sb.Append(" ShapeType: ").Append(ShapeType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -200,10 +189,10 @@ public override ShapeOrNull Read(ref Utf8JsonReader utf8JsonReader, Type typeToC throw new ArgumentNullException(nameof(shapeType), "Property is not nullable for class ShapeOrNull."); if (quadrilateral != null) - return new ShapeOrNull(quadrilateral, shapeType.Value); + return new ShapeOrNull(quadrilateral); if (triangle != null) - return new ShapeOrNull(triangle, shapeType.Value); + return new ShapeOrNull(triangle); throw new JsonException(); } @@ -221,15 +210,15 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS if (shapeOrNull.Triangle != null) { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); - triangleJsonConverter.WriteProperties(ref writer, shapeOrNull.Triangle, jsonSerializerOptions); + triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } if (shapeOrNull.Quadrilateral != null) { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); - quadrilateralJsonConverter.WriteProperties(ref writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); + quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } - WriteProperties(ref writer, shapeOrNull, jsonSerializerOptions); + WriteProperties(writer, shapeOrNull, jsonSerializerOptions); writer.WriteEndObject(); } @@ -240,12 +229,9 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonSerializerOptions jsonSerializerOptions) { - if (shapeOrNull.ShapeType == null) - throw new ArgumentNullException(nameof(shapeOrNull.ShapeType), "Property is required for class ShapeOrNull."); - writer.WriteString("shapeType", shapeOrNull.ShapeType); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs index a00a87e2efa5..3fa8bdc19177 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SimpleQuadrilateral.cs @@ -166,7 +166,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad { writer.WriteStartObject(); - WriteProperties(ref writer, simpleQuadrilateral, jsonSerializerOptions); + WriteProperties(writer, simpleQuadrilateral, jsonSerializerOptions); writer.WriteEndObject(); } @@ -177,7 +177,7 @@ public override void Write(Utf8JsonWriter writer, SimpleQuadrilateral simpleQuad /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SimpleQuadrilateral simpleQuadrilateral, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs index c91dfa5bb5fc..9b44556fcb0b 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN { writer.WriteStartObject(); - WriteProperties(ref writer, specialModelName, jsonSerializerOptions); + WriteProperties(writer, specialModelName, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs index c5651c428bd9..91ee6000335a 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Tag.cs @@ -175,7 +175,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions { writer.WriteStartObject(); - WriteProperties(ref writer, tag, jsonSerializerOptions); + WriteProperties(writer, tag, jsonSerializerOptions); writer.WriteEndObject(); } @@ -186,7 +186,7 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs index edfc91528b7b..1821b112bfb2 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordList, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordList, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs index 75205bb08c1f..433bfa41bae1 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs @@ -152,7 +152,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi { writer.WriteStartObject(); - WriteProperties(ref writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); + WriteProperties(writer, testCollectionEndingWithWordListObject, jsonSerializerOptions); writer.WriteEndObject(); } @@ -163,7 +163,7 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs index dfa2238c88a9..1cb26beb9347 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs @@ -151,7 +151,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr { writer.WriteStartObject(); - WriteProperties(ref writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); + WriteProperties(writer, testInlineFreeformAdditionalPropertiesRequest, jsonSerializerOptions); writer.WriteEndObject(); } @@ -162,7 +162,7 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index 737124e080b3..d31d2948c652 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -33,11 +33,9 @@ public partial class Triangle : IValidatableObject /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) + public Triangle(EquilateralTriangle equilateralTriangle) { EquilateralTriangle = equilateralTriangle; - TriangleType = triangleType; OnCreated(); } @@ -45,11 +43,9 @@ public Triangle(EquilateralTriangle equilateralTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) + public Triangle(IsoscelesTriangle isoscelesTriangle) { IsoscelesTriangle = isoscelesTriangle; - TriangleType = triangleType; OnCreated(); } @@ -57,11 +53,9 @@ public Triangle(IsoscelesTriangle isoscelesTriangle, string triangleType) /// Initializes a new instance of the class. /// /// - /// triangleType - public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) + public Triangle(ScaleneTriangle scaleneTriangle) { ScaleneTriangle = scaleneTriangle; - TriangleType = triangleType; OnCreated(); } @@ -82,12 +76,6 @@ public Triangle(ScaleneTriangle scaleneTriangle, string triangleType) /// public ScaleneTriangle ScaleneTriangle { get; set; } - /// - /// Gets or Sets TriangleType - /// - [JsonPropertyName("triangleType")] - public string TriangleType { get; set; } - /// /// Gets or Sets additional properties /// @@ -102,7 +90,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class Triangle {\n"); - sb.Append(" TriangleType: ").Append(TriangleType).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -223,13 +210,13 @@ public override Triangle Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv throw new ArgumentNullException(nameof(triangleType), "Property is not nullable for class Triangle."); if (equilateralTriangle != null) - return new Triangle(equilateralTriangle, triangleType.Value); + return new Triangle(equilateralTriangle); if (isoscelesTriangle != null) - return new Triangle(isoscelesTriangle, triangleType.Value); + return new Triangle(isoscelesTriangle); if (scaleneTriangle != null) - return new Triangle(scaleneTriangle, triangleType.Value); + return new Triangle(scaleneTriangle); throw new JsonException(); } @@ -247,20 +234,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali if (triangle.EquilateralTriangle != null) { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); - equilateralTriangleJsonConverter.WriteProperties(ref writer, triangle.EquilateralTriangle, jsonSerializerOptions); + equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } if (triangle.IsoscelesTriangle != null) { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); - isoscelesTriangleJsonConverter.WriteProperties(ref writer, triangle.IsoscelesTriangle, jsonSerializerOptions); + isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } if (triangle.ScaleneTriangle != null) { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); - scaleneTriangleJsonConverter.WriteProperties(ref writer, triangle.ScaleneTriangle, jsonSerializerOptions); + scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } - WriteProperties(ref writer, triangle, jsonSerializerOptions); + WriteProperties(writer, triangle, jsonSerializerOptions); writer.WriteEndObject(); } @@ -271,12 +258,9 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, Triangle triangle, JsonSerializerOptions jsonSerializerOptions) { - if (triangle.TriangleType == null) - throw new ArgumentNullException(nameof(triangle.TriangleType), "Property is required for class Triangle."); - writer.WriteString("triangleType", triangle.TriangleType); } } } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs index 270c598de618..aa6d31b91909 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TriangleInterface.cs @@ -147,7 +147,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte { writer.WriteStartObject(); - WriteProperties(ref writer, triangleInterface, jsonSerializerOptions); + WriteProperties(writer, triangleInterface, jsonSerializerOptions); writer.WriteEndObject(); } @@ -158,7 +158,7 @@ public override void Write(Utf8JsonWriter writer, TriangleInterface triangleInte /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, TriangleInterface triangleInterface, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs index 8851a6aa2ba2..a2f3e4a18a69 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/User.cs @@ -406,7 +406,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio { writer.WriteStartObject(); - WriteProperties(ref writer, user, jsonSerializerOptions); + WriteProperties(writer, user, jsonSerializerOptions); writer.WriteEndObject(); } @@ -417,7 +417,7 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs index 152369134a6d..b93046c5457b 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Whale.cs @@ -195,7 +195,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, whale, jsonSerializerOptions); + WriteProperties(writer, whale, jsonSerializerOptions); writer.WriteEndObject(); } @@ -206,7 +206,7 @@ public override void Write(Utf8JsonWriter writer, Whale whale, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Whale whale, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs index 1c364c4be9e2..c09d71736d1b 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Zebra.cs @@ -252,7 +252,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt { writer.WriteStartObject(); - WriteProperties(ref writer, zebra, jsonSerializerOptions); + WriteProperties(writer, zebra, jsonSerializerOptions); writer.WriteEndObject(); } @@ -263,7 +263,7 @@ public override void Write(Utf8JsonWriter writer, Zebra zebra, JsonSerializerOpt /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, Zebra zebra, JsonSerializerOptions jsonSerializerOptions) + 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."); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index e7baeec052c5..6e6bf0004c21 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -219,7 +219,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn { writer.WriteStartObject(); - WriteProperties(ref writer, zeroBasedEnumClass, jsonSerializerOptions); + WriteProperties(writer, zeroBasedEnumClass, jsonSerializerOptions); writer.WriteEndObject(); } @@ -230,7 +230,7 @@ public override void Write(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEn /// /// /// - public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) + public void WriteProperties(Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions) { var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value); writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);