diff --git a/.github/workflows/samples-dotnet-standard.yaml b/.github/workflows/samples-dotnet-standard.yaml index 5b6f540102ff..8d0beb672134 100644 --- a/.github/workflows/samples-dotnet-standard.yaml +++ b/.github/workflows/samples-dotnet-standard.yaml @@ -42,6 +42,8 @@ jobs: - name: Build working-directory: ${{ matrix.sample }} run: dotnet build Org.OpenAPITools.sln - - name: Test - working-directory: ${{ matrix.sample }} - run: dotnet test Org.OpenAPITools.sln + # skip tests as petstore server it not running + # these tests are run in appveyor instead + #- name: Test + # working-directory: ${{ matrix.sample }} + # run: dotnet test Org.OpenAPITools.sln diff --git a/.github/workflows/samples-dotnet.yaml b/.github/workflows/samples-dotnet.yaml index ac7ea2fd3a11..3030cf1596eb 100644 --- a/.github/workflows/samples-dotnet.yaml +++ b/.github/workflows/samples-dotnet.yaml @@ -25,7 +25,7 @@ jobs: - samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests - samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0 - samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt - - samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-useSourceGeneration + - samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration - samples/client/petstore/csharp/OpenAPIClient-generichost-net7.0-useDateTimeForDate - samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-allOf - samples/client/petstore/csharp/OpenAPIClient-generichost-netcore-latest-anyOf diff --git a/bin/configs/csharp-restsharp-net4.7.yaml b/bin/configs/csharp-restsharp-net4.7.yaml index 7222a6bbcee5..8d60715bf957 100644 --- a/bin/configs/csharp-restsharp-net4.7.yaml +++ b/bin/configs/csharp-restsharp-net4.7.yaml @@ -1,7 +1,7 @@ # for .net standard generatorName: csharp outputDir: samples/client/petstore/csharp/OpenAPIClient-net47 -inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml templateDir: modules/openapi-generator/src/main/resources/csharp additionalProperties: packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' diff --git a/bin/configs/csharp-restsharp-net4.8.yaml b/bin/configs/csharp-restsharp-net4.8.yaml index 25b55bc3b820..993e16a65465 100644 --- a/bin/configs/csharp-restsharp-net4.8.yaml +++ b/bin/configs/csharp-restsharp-net4.8.yaml @@ -1,7 +1,7 @@ # for .net standard generatorName: csharp outputDir: samples/client/petstore/csharp/OpenAPIClient-net48 -inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml templateDir: modules/openapi-generator/src/main/resources/csharp additionalProperties: packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' diff --git a/bin/configs/csharp-restsharp-net7.0.yaml b/bin/configs/csharp-restsharp-net7.0.yaml index 000d828b465b..0364bc694151 100644 --- a/bin/configs/csharp-restsharp-net7.0.yaml +++ b/bin/configs/csharp-restsharp-net7.0.yaml @@ -1,7 +1,7 @@ # for .net standard generatorName: csharp outputDir: samples/client/petstore/csharp/OpenAPIClient-net5.0 -inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml templateDir: modules/openapi-generator/src/main/resources/csharp additionalProperties: packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' diff --git a/bin/configs/csharp-restsharp-netstandard2.0.yaml b/bin/configs/csharp-restsharp-netstandard2.0.yaml index d4b6d3289833..3734d9b27635 100644 --- a/bin/configs/csharp-restsharp-netstandard2.0.yaml +++ b/bin/configs/csharp-restsharp-netstandard2.0.yaml @@ -1,7 +1,7 @@ # for .net standard generatorName: csharp outputDir: samples/client/petstore/csharp/OpenAPIClient -inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml templateDir: modules/openapi-generator/src/main/resources/csharp additionalProperties: packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}' diff --git a/bin/utils/test_file_list.yaml b/bin/utils/test_file_list.yaml index e33aaa0a7ff1..83c86255cda6 100644 --- a/bin/utils/test_file_list.yaml +++ b/bin/utils/test_file_list.yaml @@ -1,7 +1,7 @@ --- # csharp test files and image for upload - filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs" - sha256: 054adb6efaff70f492e471cb3e4d628d22cda814906808fd3fcce36ce710b7ee + sha256: e323c7e646a0ceb6d1d8f34f287175ac666fdbbe057791b45d138de3d9582666 - filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs" sha256: 7dad88554fe630d25c787cae05305d302d5e34ca810aee4fa23f20055f9188e1 - filename: "samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png" diff --git a/modules/openapi-generator/src/main/resources/csharp-functions/modelAnyOf.mustache b/modules/openapi-generator/src/main/resources/csharp-functions/modelAnyOf.mustache index fbd9fe0441d2..73db1f7f63be 100644 --- a/modules/openapi-generator/src/main/resources/csharp-functions/modelAnyOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-functions/modelAnyOf.mustache @@ -208,11 +208,37 @@ /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + {{#anyOf}} + {{#isInteger}} + case JsonToken.Integer: + return new {{classname}}(Convert.ToInt32(reader.Value)); + {{/isInteger}} + {{#isNumber}} + case JsonToken.Float: + return new {{classname}}(Convert.ToDecimal(reader.Value)); + {{/isNumber}} + {{#isString}} + case JsonToken.String: + return new {{classname}}(Convert.ToString(reader.Value)); + {{/isString}} + {{#isBoolean}} + case JsonToken.Boolean: + return new {{classname}}(Convert.ToBoolean(reader.Value)); + {{/isBoolean}} + {{#isDate}} + case JsonToken.Date: + return new {{classname}}(Convert.ToDateTime(reader.Value)); + {{/isDate}} + {{/anyOf}} + case JsonToken.StartObject: + return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return {{classname}}.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/modules/openapi-generator/src/main/resources/csharp-functions/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/csharp-functions/modelOneOf.mustache index b3a5503cba4c..4c46dbf58157 100644 --- a/modules/openapi-generator/src/main/resources/csharp-functions/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-functions/modelOneOf.mustache @@ -245,11 +245,37 @@ /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + {{#oneOf}} + {{#isInteger}} + case JsonToken.Integer: + return new {{classname}}(Convert.ToInt32(reader.Value)); + {{/isInteger}} + {{#isNumber}} + case JsonToken.Float: + return new {{classname}}(Convert.ToDecimal(reader.Value)); + {{/isNumber}} + {{#isString}} + case JsonToken.String: + return new {{classname}}(Convert.ToString(reader.Value)); + {{/isString}} + {{#isBoolean}} + case JsonToken.Boolean: + return new {{classname}}(Convert.ToBoolean(reader.Value)); + {{/isBoolean}} + {{#isDate}} + case JsonToken.Date: + return new {{classname}}(Convert.ToDateTime(reader.Value)); + {{/isDate}} + {{/oneOf}} + case JsonToken.StartObject: + return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return {{classname}}.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/modules/openapi-generator/src/main/resources/csharp/modelAnyOf.mustache b/modules/openapi-generator/src/main/resources/csharp/modelAnyOf.mustache index c206bc656044..9b17ec27bc31 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelAnyOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelAnyOf.mustache @@ -227,11 +227,39 @@ /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + {{#composedSchemas.anyOf}} + {{^vendorExtensions.x-duplicated-data-type}} + {{#isInteger}} + case JsonToken.Integer: + return new {{classname}}(Convert.ToInt32(reader.Value)); + {{/isInteger}} + {{#isNumber}} + case JsonToken.Float: + return new {{classname}}(Convert.ToDecimal(reader.Value)); + {{/isNumber}} + {{#isString}} + case JsonToken.String: + return new {{classname}}(Convert.ToString(reader.Value)); + {{/isString}} + {{#isBoolean}} + case JsonToken.Boolean: + return new {{classname}}(Convert.ToBoolean(reader.Value)); + {{/isBoolean}} + {{#isDate}} + case JsonToken.Date: + return new {{classname}}(Convert.ToDateTime(reader.Value)); + {{/isDate}} + {{/vendorExtensions.x-duplicated-data-type}} + {{/composedSchemas.anyOf}} + case JsonToken.StartObject: + return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return {{classname}}.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/modules/openapi-generator/src/main/resources/csharp/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/csharp/modelOneOf.mustache index 60e7ce906726..f9c39b02cd2d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/modelOneOf.mustache @@ -272,11 +272,39 @@ /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + {{#composedSchemas.oneOf}} + {{^vendorExtensions.x-duplicated-data-type}} + {{#isInteger}} + case JsonToken.Integer: + return new {{classname}}(Convert.ToInt32(reader.Value)); + {{/isInteger}} + {{#isNumber}} + case JsonToken.Float: + return new {{classname}}(Convert.ToDecimal(reader.Value)); + {{/isNumber}} + {{#isString}} + case JsonToken.String: + return new {{classname}}(Convert.ToString(reader.Value)); + {{/isString}} + {{#isBoolean}} + case JsonToken.Boolean: + return new {{classname}}(Convert.ToBoolean(reader.Value)); + {{/isBoolean}} + {{#isDate}} + case JsonToken.Date: + return new {{classname}}(Convert.ToDateTime(reader.Value)); + {{/isDate}} + {{/vendorExtensions.x-duplicated-data-type}} + {{/composedSchemas.oneOf}} + case JsonToken.StartObject: + return {{classname}}.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return {{classname}}.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml new file mode 100644 index 000000000000..8828ce072268 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature-oneof-primitive-types.yaml @@ -0,0 +1,2806 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /roles/report: + get: + responses: + '200': + description: returns report + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/RolesReport' + /hello: + get: + summary: Hello + description: Hello + operationId: Hello + responses: + '200': + description: UUIDs + content: + application/json: + schema: + type: array + items: + type: string + format: uuid + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '405': + description: Invalid input + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + deprecated: true + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + - api_key_query: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generate exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + Set-Cookie: + description: >- + Cookie authentication key for use with the `api_key` + apiKey authentication. + schema: + type: string + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + '598': + description: Not a real HTTP status code + '599': + description: Not a real HTTP status code with a return object + content: + application/json: + schema: + $ref: '#/components/schemas/User' + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + responses: + '400': + description: Invalid request + '404': + description: Not found + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + description: Form parameter enum test (string) + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + default: '2010-02-01T10:20:10.11111+01:00' + example: '2020-02-02T20:20:20.22222Z' + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Something wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + parameters: + - name: required_string_uuid + in: query + description: Required UUID String + required: true + schema: + type: string + format: uuid + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/additionalProperties-reference: + post: + tags: + - fake + summary: test referenced additionalProperties + description: '' + operationId: testAdditionalPropertiesReference + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FreeFormObject' + description: request body + required: true + /fake/stringMap-reference: + post: + tags: + - fake + summary: test referenced string map + description: '' + operationId: testStringMapReference + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MapOfString' + description: request body + required: true + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/inline-freeform-additionalProperties: + post: + tags: + - fake + summary: test inline free-form additionalProperties + description: '' + operationId: testInlineFreeformAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + properties: + someProperty: + type: string + additionalProperties: true + description: request body + required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: '123_test_@#$%_special_tags' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: >- + For this test, the body for this request much reference a schema named + `File`. + operationId: testBodyWithFileSchema + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + /fake/test-query-parameters: + put: + tags: + - fake + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + - name: requiredNotNullable + in: query + required: true + explode: true + schema: + type: string + nullable: false + - name: requiredNullable + in: query + required: true + explode: true + schema: + type: string + nullable: true + - name: notRequiredNotNullable + in: query + required: false + explode: true + schema: + type: string + nullable: false + - name: notRequiredNullable + in: query + required: false + explode: true + schema: + type: string + nullable: true + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: + # Export data as Excel spreadsheet. + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' + /fake/array-of-enums: + get: + tags: + - fake + summary: Array of Enums + operationId: getArrayOfEnums + responses: + 200: + description: Got named array of enums + content: + application/json: + schema: + $ref: '#/components/schemas/ArrayOfEnums' + /fake/mixed/anyOf: + get: + tags: + - fake + summary: Test mixed type anyOf deserialization + operationId: getMixedAnyOf + responses: + 200: + description: Got mixed anyOf + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + /fake/mixed/oneOf: + get: + tags: + - fake + summary: Test mixed type oneOf deserialization + operationId: getMixedOneOf + responses: + 200: + description: Got mixed oneOf + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + /country: + post: + operationId: getCountry + requestBody: + content: + application/x-www-form-urlencoded: + schema: + allOf: + - required: + - country + type: object + properties: + country: + type: string + responses: + '200': + description: OK + /test: + get: + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/notificationtest-getElements-v1-Response-mPayload' + description: Successful response + operationId: Test + summary: Retrieve an existing Notificationtest's Elements +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' + - url: https://127.0.0.1/no_variable + description: The local server without variables +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + examples: + simple-list: + summary: Simple list example + description: Should not get into code examples + value: + - username: foo + - username: bar + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + # Test the 'HTTP signature' security scheme. + # Each HTTP request is cryptographically signed as specified + # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ + type: http + scheme: signature + schemas: + RolesReport: + description: Roles report + type: array + items: + $ref: '#/components/schemas/RolesReportsHash' + RolesReportsHash: + description: Role report Hash + type: object + properties: + role_uuid: + type: string + format: uuid + role: + type: object + properties: + name: + type: string + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + example: '2020-02-02T20:20:20.000222Z' + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + objectWithNoDeclaredProps: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for objects + Value must be a map of strings to values. It cannot be the 'null' value. + objectWithNoDeclaredPropsNullable: + type: object + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + description: test code generation for nullable objects. + Value must be a map of strings to values or the 'null' value. + nullable: true + anyTypeProp: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + See https://github.com/OAI/OpenAPI-Specification/issues/1389 + # TODO: this should be supported, currently there are some issues in the code generation. + #anyTypeExceptNullProp: + # description: any type except 'null' + # Here the 'type' attribute is not specified, which means the value can be anything, + # including the null value, string, number, boolean, array or object. + # not: + # type: 'null' + anyTypePropNullable: + description: test code generation for any type + Here the 'type' attribute is not specified, which means the value can be anything, + including the null value, string, number, boolean, array or object. + The 'nullable' attribute does not change the allowed values. + nullable: true + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' + - type: object + properties: + declawed: + type: boolean + Address: + type: object + additionalProperties: + type: integer + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + multipleOf: 2 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + unsigned_integer: + type: integer + format: int32 + maximum: 200 + minimum: 20 + x-unsigned: true + int64: + type: integer + format: int64 + unsigned_long: + type: integer + format: int64 + x-unsigned: true + number: + maximum: 543.2 + minimum: 32.1 + type: number + multipleOf: 32.5 + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + decimal: + type: string + format: number + string: + type: string + pattern: '/[a-z]/i' + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + example: '2020-02-02' + dateTime: + type: string + format: date-time + example: '2007-12-03T10:15:30+01:00' + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + pattern_with_backslash: + description: None + type: string + pattern: '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$' + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Outer_Enum_Test: + type: string + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_integer_only: + type: integer + enum: + - 2 + - -2 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + anytype_1: {} + map_with_undeclared_properties_anytype_1: + type: object + map_with_undeclared_properties_anytype_2: + type: object + properties: {} + map_with_undeclared_properties_anytype_3: + type: object + additionalProperties: true + empty_map: + type: object + description: an object with no declared properties and no undeclared + properties, hence it's an empty map. + additionalProperties: false + map_with_undeclared_properties_string: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid_with_pattern: + type: string + format: uuid + pattern: "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + x-cls-compliant: true + x-com-visible: true + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + FreeFormObject: + type: object + description: A schema consisting only of additional properties + additionalProperties: true + MapOfString: + type: object + description: A schema consisting only of additional properties of type string + additionalProperties: + type: string + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - 0 + - 1 + - 2 + default: 0 + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + FileSchemaTestClass: + type: object + properties: + file: + $ref: '#/components/schemas/File' + files: + type: array + items: + $ref: '#/components/schemas/File' + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + '_special_model.name_': + type: string + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + RequiredClass: + type: object + properties: + required_nullable_integer_prop: + type: integer + nullable: true + required_notnullableinteger_prop: + type: integer + nullable: false + not_required_nullable_integer_prop: + type: integer + nullable: true + not_required_notnullableinteger_prop: + type: integer + nullable: false + + required_nullable_string_prop: + type: string + nullable: true + required_notnullable_string_prop: + type: string + nullable: false + notrequired_nullable_string_prop: + type: string + nullable: true + notrequired_notnullable_string_prop: + type: string + nullable: false + + required_nullable_boolean_prop: + type: boolean + nullable: true + required_notnullable_boolean_prop: + type: boolean + nullable: false + notrequired_nullable_boolean_prop: + type: boolean + nullable: true + notrequired_notnullable_boolean_prop: + type: boolean + nullable: false + + required_nullable_date_prop: + type: string + format: date + nullable: true + required_not_nullable_date_prop: + type: string + format: date + nullable: false + not_required_nullable_date_prop: + type: string + format: date + nullable: true + not_required_notnullable_date_prop: + type: string + format: date + nullable: false + + required_notnullable_datetime_prop: + type: string + format: date-time + nullable: false + required_nullable_datetime_prop: + type: string + format: date-time + nullable: true + notrequired_nullable_datetime_prop: + type: string + format: date-time + nullable: true + notrequired_notnullable_datetime_prop: + type: string + format: date-time + nullable: false + + required_nullable_enum_integer: + type: integer + format: int32 + nullable: true + enum: + - 1 + - -1 + required_notnullable_enum_integer: + type: integer + format: int32 + nullable: false + enum: + - 1 + - -1 + notrequired_nullable_enum_integer: + type: integer + format: int32 + nullable: true + enum: + - 1 + - -1 + notrequired_notnullable_enum_integer: + type: integer + format: int32 + nullable: false + enum: + - 1 + - -1 + + required_nullable_enum_integer_only: + type: integer + nullable: true + enum: + - 2 + - -2 + required_notnullable_enum_integer_only: + type: integer + nullable: false + enum: + - 2 + - -2 + notrequired_nullable_enum_integer_only: + type: integer + nullable: true + enum: + - 2 + - -2 + notrequired_notnullable_enum_integer_only: + type: integer + nullable: false + enum: + - 2 + - -2 + + required_notnullable_enum_string: + type: string + nullable: false + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + required_nullable_enum_string: + type: string + nullable: true + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + notrequired_nullable_enum_string: + type: string + nullable: true + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + notrequired_notnullable_enum_string: + type: string + nullable: false + enum: + - UPPER + - lower + - '' + - "Value\twith tab" + - 'Value with " quote' + - 'Value with escaped \" quote' + - "Duplicate\nvalue" + - "Duplicate\r\nvalue" + + required_nullable_outerEnumDefaultValue: + nullable: true + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + required_notnullable_outerEnumDefaultValue: + nullable: false + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + notrequired_nullable_outerEnumDefaultValue: + nullable: true + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + notrequired_notnullable_outerEnumDefaultValue: + nullable: false + allOf: + - $ref: '#/components/schemas/OuterEnumDefaultValue' + + required_nullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: true + required_notnullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: false + notrequired_nullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: true + notrequired_notnullable_uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: false + + required_nullable_array_of_string: + type: array + nullable: true + items: + type: string + required_notnullable_array_of_string: + type: array + nullable: false + items: + type: string + notrequired_nullable_array_of_string: + type: array + nullable: true + items: + type: string + notrequired_notnullable_array_of_string: + type: array + nullable: false + items: + type: string + required: + - required_nullable_boolean_prop + - required_notnullable_boolean_prop + - required_nullable_string_prop + - required_notnullable_string_prop + - required_nullable_integer_prop + - required_notnullableinteger_prop + - required_nullable_date_prop + - required_not_nullable_date_prop + - required_notnullable_datetime_prop + - required_nullable_datetime_prop + - required_nullable_enum_integer + - required_notnullable_enum_integer + - required_nullable_enum_integer_only + - required_notnullable_enum_integer_only + - required_notnullable_enum_string + - required_nullable_enum_string + - required_nullable_outerEnumDefaultValue + - required_notnullable_outerEnumDefaultValue + - required_nullable_uuid + - required_notnullable_uuid + - required_nullable_array_of_string + - required_notnullable_array_of_string + NullableClass: + type: object + properties: + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + fruit: + properties: + color: + type: string + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + # Below additionalProperties is set to false to validate the use + # case when a composed schema has additionalProperties set to false. + additionalProperties: false + apple: + type: object + properties: + cultivar: + type: string + pattern: ^[a-zA-Z\s]*$ + origin: + type: string + pattern: /^[A-Z\s]*$/i + color_code: + type: string + pattern: ^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$ + nullable: true + banana: + type: object + properties: + lengthCm: + type: number + mammal: + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + - $ref: '#/components/schemas/Pig' + discriminator: + propertyName: className + whale: + type: object + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + zebra: + type: object + properties: + type: + type: string + enum: + - plains + - mountain + - grevys + className: + type: string + required: + - className + additionalProperties: true + Pig: + oneOf: + - $ref: '#/components/schemas/BasquePig' + - $ref: '#/components/schemas/DanishPig' + discriminator: + propertyName: className + BasquePig: + type: object + properties: + className: + type: string + required: + - className + DanishPig: + type: object + properties: + className: + type: string + required: + - className + gmFruit: + properties: + color: + type: string + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + additionalProperties: false + fruitReq: + oneOf: + - type: 'null' + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + additionalProperties: false + appleReq: + type: object + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + additionalProperties: false + bananaReq: + type: object + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + additionalProperties: false + # go-experimental is unable to make Triangle and Quadrilateral models + # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149 + Drawing: + type: object + properties: + mainShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value cannot be null. + $ref: '#/components/schemas/Shape' + shapeOrNull: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because ShapeOrNull has 'null' + # type as a child schema of 'oneOf'. + $ref: '#/components/schemas/ShapeOrNull' + nullableShape: + # A property whose value is a 'oneOf' type, and the type is referenced instead + # of being defined inline. The value may be null because NullableShape has the + # 'nullable: true' attribute. For this specific scenario this is exactly the + # same thing as 'shapeOrNull'. + $ref: '#/components/schemas/NullableShape' + shapes: + type: array + items: + $ref: '#/components/schemas/Shape' + additionalProperties: + # Here the additional properties are specified using a referenced schema. + # This is just to validate the generated code works when using $ref + # under 'additionalProperties'. + $ref: '#/components/schemas/fruit' + Shape: + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + ShapeOrNull: + description: The value may be a shape or the 'null' value. + This is introduced in OAS schema >= 3.1. + oneOf: + - type: 'null' + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + NullableShape: + description: The value may be a shape or the 'null' value. + The 'nullable' attribute was introduced in OAS schema >= 3.0 + and has been deprecated in OAS schema >= 3.1. + oneOf: + - $ref: '#/components/schemas/Triangle' + - $ref: '#/components/schemas/Quadrilateral' + discriminator: + propertyName: shapeType + nullable: true + ShapeInterface: + properties: + shapeType: + type: string + required: + - shapeType + TriangleInterface: + properties: + triangleType: + type: string + required: + - triangleType + Triangle: + oneOf: + - $ref: '#/components/schemas/EquilateralTriangle' + - $ref: '#/components/schemas/IsoscelesTriangle' + - $ref: '#/components/schemas/ScaleneTriangle' + discriminator: + propertyName: triangleType + # Note: the 'additionalProperties' keyword is not specified, which is + # equivalent to allowing undeclared properties of any type. + EquilateralTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + IsoscelesTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + additionalProperties: false + ScaleneTriangle: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/TriangleInterface' + QuadrilateralInterface: + properties: + quadrilateralType: + type: string + required: + - quadrilateralType + Quadrilateral: + oneOf: + - $ref: '#/components/schemas/SimpleQuadrilateral' + - $ref: '#/components/schemas/ComplexQuadrilateral' + discriminator: + propertyName: quadrilateralType + SimpleQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + ComplexQuadrilateral: + allOf: + - $ref: '#/components/schemas/ShapeInterface' + - $ref: '#/components/schemas/QuadrilateralInterface' + GrandparentAnimal: + type: object + required: + - pet_type + properties: + pet_type: + type: string + discriminator: + propertyName: pet_type + ParentPet: + type: object + allOf: + - $ref: '#/components/schemas/GrandparentAnimal' + ChildCat: + allOf: + - $ref: '#/components/schemas/ParentPet' + - type: object + properties: + name: + type: string + pet_type: + x-enum-as-string: true + type: string + enum: + - ChildCat + default: ChildCat + required: + - pet_type + ArrayOfEnums: + type: array + items: + $ref: '#/components/schemas/OuterEnum' + DateTimeTest: + type: string + default: '2010-01-01T10:10:10.000111+01:00' + example: '2010-01-01T10:10:10.000111+01:00' + format: date-time + DeprecatedObject: + type: object + deprecated: true + properties: + name: + type: string + ObjectWithDeprecatedFields: + type: object + properties: + uuid: + type: string + id: + type: number + deprecated: true + deprecatedRef: + $ref: '#/components/schemas/DeprecatedObject' + bars: + type: array + deprecated: true + items: + $ref: '#/components/schemas/Bar' + PolymorphicProperty: + oneOf: + - type: boolean + - type: string + - type: object + - type: array + items: + $ref: '#/components/schemas/StringArrayItem' + StringArrayItem: + type: string + format: string + Activity: + description: "test map of maps" + type: object + properties: + activity_outputs: + type: object + additionalProperties: + $ref: '#/components/schemas/ActivityOutputRepresentation' + ActivityOutputRepresentation: + type: array + items: + $ref: '#/components/schemas/ActivityOutputElementRepresentation' + ActivityOutputElementRepresentation: + type: object + properties: + prop1: + type: string + prop2: + type: object + NullableGuidClass: + type: object + properties: + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + nullable: true + DateOnlyClass: + type: object + properties: + dateOnlyProperty: + type: string + format: date + example: "2017-07-21" + TestCollectionEndingWithWordListObject: + type: object + properties: + TestCollectionEndingWithWordList: + type: array + items: + $ref: '#/components/schemas/TestCollectionEndingWithWordList' + TestCollectionEndingWithWordList: + type: object + properties: + value: + type: string + LiteralStringClass: + type: object + properties: + escapedLiteralString: + type: string + default: C:\\Users\\username + unescapedLiteralString: + type: string + default: C:\Users\username + OneOfString: + oneOf: + - type: string + pattern: ^a + - type: string + pattern: ^b + ZeroBasedEnum: + type: string + enum: + - unknown + - notUnknown + ZeroBasedEnumClass: + type: object + properties: + ZeroBasedEnum: + type: string + enum: + - unknown + - notUnknown + Custom-Variableobject-Response: + description: A Variable object without predefined property names + type: object + additionalProperties: true + Field-pkiNotificationtestID: + type: integer + notificationtest-getElements-v1-Response-mPayload: + required: + - pkiNotificationtestID + - a_objVariableobject + type: object + properties: + pkiNotificationtestID: + $ref: '#/components/schemas/Field-pkiNotificationtestID' + a_objVariableobject: + type: array + items: + $ref: '#/components/schemas/Custom-Variableobject-Response' + MixedOneOf: + properties: + content: + oneOf: + - type: string + - type: boolean + # JsonReader will give back C# System.Int64 regardless of format. + - type: integer + format: uint8 + # JsonReader will give back C# System.Double regardless of format. + - type: number + format: float32 + - type: object + $ref: '#/components/schemas/MixedSubId' + description: Mixed oneOf types for testing + MixedAnyOf: + properties: + content: + anyOf: + - type: string + - type: boolean + # JsonReader will give back C# System.Int64 regardless of format. + - type: integer + format: uint8 + # JsonReader will give back C# System.Double regardless of format. + - type: number + format: float32 + - type: object + $ref: '#/components/schemas/MixedSubId' + + description: Mixed anyOf types for testing + MixedSubId: + properties: + id: + type: string \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Mammal.cs index 39a999e581cb..fdd59ea3787f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Mammal.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableShape.cs index 8478eec11933..9387dcff85ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableShape.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Pig.cs index 5363ba83ae71..fda1f010d9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Pig.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Quadrilateral.cs index 13087e6b4549..b3c52fb39dec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Shape.cs index 7cfa900bcf67..a3c9ca29a4be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Shape.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1d618195f4c7..bdf09a757acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Triangle.cs index a410bce92bf2..619915332307 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Triangle.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/Org.OpenAPITools.sln b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/Org.OpenAPITools.sln new file mode 100644 index 000000000000..6f2442d00e53 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/Org.OpenAPITools.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.0.0 +MinimumVisualStudioVersion = 10.0.0.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UseSourceGeneration", "src\UseSourceGeneration\UseSourceGeneration.csproj", "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UseSourceGeneration.Test", "src\UseSourceGeneration.Test\UseSourceGeneration.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {321C8C3F-0156-40C1-AE42-D59761FB9B6C}.Release|Any CPU.Build.0 = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Api/FakeApiTests.cs index aff5eb0b28de..67bdbe68a0f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Api/FakeApiTests.cs @@ -121,6 +121,16 @@ namespace UseSourceGeneration.Test.Api Assert.IsType>(model); } + /// + /// Test TestAdditionalPropertiesReference + /// + [Fact (Skip = "not implemented")] + public async Task TestAdditionalPropertiesReferenceAsyncTest() + { + Dictionary requestBody = default!; + await _instance.TestAdditionalPropertiesReferenceAsync(requestBody); + } + /// /// Test TestBodyWithFileSchema /// @@ -164,7 +174,7 @@ namespace UseSourceGeneration.Test.Api decimal number = default!; double varDouble = default!; string patternWithoutDelimiter = default!; - Client.Option date = default!; + Client.Option date = default!; Client.Option binary = default!; Client.Option varFloat = default!; Client.Option integer = default!; @@ -257,5 +267,15 @@ namespace UseSourceGeneration.Test.Api Client.Option notRequiredNullable = default!; await _instance.TestQueryParameterCollectionFormatAsync(pipe, ioutil, http, url, context, requiredNotNullable, requiredNullable, notRequiredNotNullable, notRequiredNullable); } + + /// + /// Test TestStringMapReference + /// + [Fact (Skip = "not implemented")] + public async Task TestStringMapReferenceAsyncTest() + { + Dictionary requestBody = default!; + await _instance.TestStringMapReferenceAsync(requestBody); + } } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..f9ebedcec9e0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using UseSourceGeneration.Model; +using UseSourceGeneration.Client; +using System.Reflection; + +namespace UseSourceGeneration.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..f2641ddd9844 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using UseSourceGeneration.Model; +using UseSourceGeneration.Client; +using System.Reflection; + +namespace UseSourceGeneration.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..9e14dfd3c6df --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using UseSourceGeneration.Model; +using UseSourceGeneration.Client; +using System.Reflection; + +namespace UseSourceGeneration.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..e27750c9c1fe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..1513de7a320c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..e27750c9c1fe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..1513de7a320c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..e27750c9c1fe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..1513de7a320c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,56 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCatAllOf.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOf.md similarity index 64% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCatAllOf.md rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOf.md index 864d33e80e7a..6a6aa093bebe 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCatAllOf.md +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOf.md @@ -1,11 +1,10 @@ -# Org.OpenAPITools.Model.ChildCatAllOf +# Org.OpenAPITools.Model.MixedAnyOf ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | **string** | | [optional] -**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat] +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/DogAllOf.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedEnumType.md similarity index 78% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/DogAllOf.md rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedEnumType.md index c1096f2c3105..24385b3ae84f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/DogAllOf.md +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedEnumType.md @@ -1,10 +1,9 @@ -# Org.OpenAPITools.Model.DogAllOf +# Org.OpenAPITools.Model.MixedEnumType ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Breed** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/CatAllOf.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedNullableEnumType.md similarity index 78% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/CatAllOf.md rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedNullableEnumType.md index 6cbaaa14e814..a38369d002d1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/CatAllOf.md +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedNullableEnumType.md @@ -1,10 +1,9 @@ -# Org.OpenAPITools.Model.CatAllOf +# Org.OpenAPITools.Model.MixedNullableEnumType ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Declawed** | **bool** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/UpdatePet200Response.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedSubId.md similarity index 73% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/UpdatePet200Response.md rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedSubId.md index d1625d266647..b9268e37cba6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/UpdatePet200Response.md +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/MixedSubId.md @@ -1,10 +1,10 @@ -# Org.OpenAPITools.Model.UpdatePet200Response +# Org.OpenAPITools.Model.MixedSubId ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**VarString** | [**Pet**](Pet.md) | | [optional] +**Id** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs index f15f90cf1167..d85751aa172e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Fruit.cs @@ -271,11 +271,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs index a283729f374c..8e04deec3f3f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/FruitReq.cs @@ -280,11 +280,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs index 2eb305679d51..f71696c08ae6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/GmFruit.cs @@ -244,11 +244,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs index 0fb334cf7ae7..c7adc58517c4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Mammal.cs @@ -344,11 +344,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DogAllOf.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOf.cs similarity index 70% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DogAllOf.cs rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOf.cs index f6e4e068c9b0..a24d6d59d78d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DogAllOf.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -21,55 +21,34 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model { /// - /// DogAllOf + /// MixedAnyOf /// - [DataContract(Name = "Dog_allOf")] - public partial class DogAllOf : IEquatable, IValidatableObject + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// breed. - public DogAllOf(string breed = default(string)) + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) { - this._Breed = breed; - if (this.Breed != null) - { - this._flagBreed = true; - } + this.Content = content; this.AdditionalProperties = new Dictionary(); } /// - /// Gets or Sets Breed + /// Gets or Sets Content /// - [DataMember(Name = "breed", EmitDefaultValue = false)] - public string Breed - { - get{ return _Breed;} - set - { - _Breed = value; - _flagBreed = true; - } - } - private string _Breed; - private bool _flagBreed; + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } - /// - /// Returns false as Breed should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeBreed() - { - return _flagBreed; - } /// /// Gets or Sets additional properties /// @@ -83,8 +62,8 @@ namespace Org.OpenAPITools.Model public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class DogAllOf {\n"); - sb.Append(" Breed: ").Append(Breed).Append("\n"); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -106,15 +85,15 @@ namespace Org.OpenAPITools.Model /// Boolean public override bool Equals(object input) { - return OpenAPIClientUtils.compareLogic.Compare(this, input as DogAllOf).AreEqual; + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; } /// - /// Returns true if DogAllOf instances are equal + /// Returns true if MixedAnyOf instances are equal /// - /// Instance of DogAllOf to be compared + /// Instance of MixedAnyOf to be compared /// Boolean - public bool Equals(DogAllOf input) + public bool Equals(MixedAnyOf input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -128,9 +107,9 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.Breed != null) + if (this.Content != null) { - hashCode = (hashCode * 59) + this.Breed.GetHashCode(); + hashCode = (hashCode * 59) + this.Content.GetHashCode(); } if (this.AdditionalProperties != null) { diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..9246bd37981c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,391 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..9614f6d0dbe5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,49 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..7380e302de9c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,55 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/CatAllOf.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOf.cs similarity index 69% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/CatAllOf.cs rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOf.cs index 5b5f9e03d732..a849aa8eefe7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/CatAllOf.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -21,55 +21,34 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model { /// - /// CatAllOf + /// MixedOneOf /// - [DataContract(Name = "Cat_allOf")] - public partial class CatAllOf : IEquatable, IValidatableObject + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// declawed. - public CatAllOf(bool declawed = default(bool)) + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) { - this._Declawed = declawed; - if (this.Declawed != null) - { - this._flagDeclawed = true; - } + this.Content = content; this.AdditionalProperties = new Dictionary(); } /// - /// Gets or Sets Declawed + /// Gets or Sets Content /// - [DataMember(Name = "declawed", EmitDefaultValue = true)] - public bool Declawed - { - get{ return _Declawed;} - set - { - _Declawed = value; - _flagDeclawed = true; - } - } - private bool _Declawed; - private bool _flagDeclawed; + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } - /// - /// Returns false as Declawed should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeDeclawed() - { - return _flagDeclawed; - } /// /// Gets or Sets additional properties /// @@ -83,8 +62,8 @@ namespace Org.OpenAPITools.Model public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class CatAllOf {\n"); - sb.Append(" Declawed: ").Append(Declawed).Append("\n"); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -106,15 +85,15 @@ namespace Org.OpenAPITools.Model /// Boolean public override bool Equals(object input) { - return OpenAPIClientUtils.compareLogic.Compare(this, input as CatAllOf).AreEqual; + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; } /// - /// Returns true if CatAllOf instances are equal + /// Returns true if MixedOneOf instances are equal /// - /// Instance of CatAllOf to be compared + /// Instance of MixedOneOf to be compared /// Boolean - public bool Equals(CatAllOf input) + public bool Equals(MixedOneOf input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -128,7 +107,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - hashCode = (hashCode * 59) + this.Declawed.GetHashCode(); + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..b077d0a7b6ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,442 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/UpdatePet200Response.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedSubId.cs similarity index 67% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/UpdatePet200Response.cs rename to samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedSubId.cs index 2afd485edd84..a12a31aa13af 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/UpdatePet200Response.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -21,55 +21,34 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model { /// - /// UpdatePet200Response + /// MixedSubId /// - [DataContract(Name = "updatePet_200_response")] - public partial class UpdatePet200Response : IEquatable, IValidatableObject + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// varString. - public UpdatePet200Response(Pet varString = default(Pet)) + /// id. + public MixedSubId(string id = default(string)) { - this._VarString = varString; - if (this.VarString != null) - { - this._flagVarString = true; - } + this.Id = id; this.AdditionalProperties = new Dictionary(); } /// - /// Gets or Sets VarString + /// Gets or Sets Id /// - [DataMember(Name = "string", EmitDefaultValue = false)] - public Pet VarString - { - get{ return _VarString;} - set - { - _VarString = value; - _flagVarString = true; - } - } - private Pet _VarString; - private bool _flagVarString; + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } - /// - /// Returns false as VarString should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeVarString() - { - return _flagVarString; - } /// /// Gets or Sets additional properties /// @@ -83,8 +62,8 @@ namespace Org.OpenAPITools.Model public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class UpdatePet200Response {\n"); - sb.Append(" VarString: ").Append(VarString).Append("\n"); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -106,15 +85,15 @@ namespace Org.OpenAPITools.Model /// Boolean public override bool Equals(object input) { - return OpenAPIClientUtils.compareLogic.Compare(this, input as UpdatePet200Response).AreEqual; + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; } /// - /// Returns true if UpdatePet200Response instances are equal + /// Returns true if MixedSubId instances are equal /// - /// Instance of UpdatePet200Response to be compared + /// Instance of MixedSubId to be compared /// Boolean - public bool Equals(UpdatePet200Response input) + public bool Equals(MixedSubId input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -128,9 +107,9 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.VarString != null) + if (this.Id != null) { - hashCode = (hashCode * 59) + this.VarString.GetHashCode(); + hashCode = (hashCode * 59) + this.Id.GetHashCode(); } if (this.AdditionalProperties != null) { diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs index e3f4c136f97b..b4a865094f00 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableShape.cs @@ -304,11 +304,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OneOfString.cs index d35b24a365d3..9da14f87d7e2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/OneOfString.cs @@ -225,11 +225,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs index ad5284a41246..55f89cc00b08 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Pig.cs @@ -295,11 +295,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index a0cdae58c19e..a6f17110c4f3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -363,11 +363,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs index 7d6996b47832..e88706b57c55 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -295,11 +295,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs index 004e77a20938..2db1b6679419 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Shape.cs @@ -295,11 +295,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs index cc32eae9890d..785941e64e23 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -304,11 +304,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs index 37656e89af2f..f1e8edba8350 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Triangle.cs @@ -344,11 +344,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES index 1e54de3472d2..c6424794961a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/.openapi-generator/FILES @@ -51,7 +51,12 @@ docs/List.md docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -174,7 +179,12 @@ src/Org.OpenAPITools/Model/List.cs src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/README.md b/samples/client/petstore/csharp/OpenAPIClient-net47/README.md index d3de689dee76..ff2b83aeb247 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/README.md @@ -127,6 +127,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -210,7 +212,12 @@ Class | Method | HTTP request | Description - [Model.LiteralStringClass](docs/LiteralStringClass.md) - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml index 1845b502818e..673de491c712 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2692,6 +2718,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string _foo_get_default_response: example: string: @@ -2856,6 +2898,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/FakeApi.md index 356154a4b991..06309f31e8a5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/FakeApi.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Api/FakeApi.cs index bc6276012d1e..82d3054c5a90 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ namespace Org.OpenAPITools.Api /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ namespace Org.OpenAPITools.Api /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Mammal.cs index 39a999e581cb..fdd59ea3787f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Mammal.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCatAllOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOf.cs similarity index 55% rename from samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCatAllOf.cs rename to samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOf.cs index 3358b79784ff..6618a26476f1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCatAllOf.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -27,89 +27,27 @@ using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; namespace Org.OpenAPITools.Model { /// - /// ChildCatAllOf + /// MixedAnyOf /// - [DataContract(Name = "ChildCat_allOf")] - public partial class ChildCatAllOf : IEquatable, IValidatableObject + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject { /// - /// Defines PetType + /// Initializes a new instance of the class. /// - [JsonConverter(typeof(StringEnumConverter))] - public enum PetTypeEnum + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) { - /// - /// Enum ChildCat for value: ChildCat - /// - [EnumMember(Value = "ChildCat")] - ChildCat = 1 - } - - - /// - /// Gets or Sets PetType - /// - - [DataMember(Name = "pet_type", EmitDefaultValue = false)] - public PetTypeEnum? PetType - { - get{ return _PetType;} - set - { - _PetType = value; - _flagPetType = true; - } - } - private PetTypeEnum? _PetType; - private bool _flagPetType; - - /// - /// Returns false as PetType should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializePetType() - { - return _flagPetType; - } - /// - /// Initializes a new instance of the class. - /// - /// name. - /// petType (default to PetTypeEnum.ChildCat). - public ChildCatAllOf(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) - { - this._Name = name; - if (this.Name != null) - { - this._flagName = true; - } + this.Content = content; this.AdditionalProperties = new Dictionary(); } /// - /// Gets or Sets Name + /// Gets or Sets Content /// - [DataMember(Name = "name", EmitDefaultValue = false)] - public string Name - { - get{ return _Name;} - set - { - _Name = value; - _flagName = true; - } - } - private string _Name; - private bool _flagName; + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } - /// - /// Returns false as Name should not be serialized given that it's read-only. - /// - /// false (boolean) - public bool ShouldSerializeName() - { - return _flagName; - } /// /// Gets or Sets additional properties /// @@ -123,9 +61,8 @@ namespace Org.OpenAPITools.Model public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ChildCatAllOf {\n"); - sb.Append(" Name: ").Append(Name).Append("\n"); - sb.Append(" PetType: ").Append(PetType).Append("\n"); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -147,15 +84,15 @@ namespace Org.OpenAPITools.Model /// Boolean public override bool Equals(object input) { - return OpenAPIClientUtils.compareLogic.Compare(this, input as ChildCatAllOf).AreEqual; + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; } /// - /// Returns true if ChildCatAllOf instances are equal + /// Returns true if MixedAnyOf instances are equal /// - /// Instance of ChildCatAllOf to be compared + /// Instance of MixedAnyOf to be compared /// Boolean - public bool Equals(ChildCatAllOf input) + public bool Equals(MixedAnyOf input) { return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; } @@ -169,11 +106,10 @@ namespace Org.OpenAPITools.Model unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.Name != null) + if (this.Content != null) { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); + hashCode = (hashCode * 59) + this.Content.GetHashCode(); } - hashCode = (hashCode * 59) + this.PetType.GetHashCode(); if (this.AdditionalProperties != null) { hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..95b561a9f076 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..166feb8ea602 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..6d208f3d9f66 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..313d4f8a5f14 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableShape.cs index 8478eec11933..9387dcff85ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableShape.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pig.cs index 5363ba83ae71..fda1f010d9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Pig.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Quadrilateral.cs index 13087e6b4549..b3c52fb39dec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Shape.cs index 7cfa900bcf67..a3c9ca29a4be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Shape.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1d618195f4c7..bdf09a757acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Triangle.cs index a410bce92bf2..619915332307 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Triangle.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES index 1e54de3472d2..c6424794961a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/.openapi-generator/FILES @@ -51,7 +51,12 @@ docs/List.md docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -174,7 +179,12 @@ src/Org.OpenAPITools/Model/List.cs src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/README.md b/samples/client/petstore/csharp/OpenAPIClient-net48/README.md index d3de689dee76..ff2b83aeb247 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/README.md @@ -127,6 +127,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -210,7 +212,12 @@ Class | Method | HTTP request | Description - [Model.LiteralStringClass](docs/LiteralStringClass.md) - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml index 1845b502818e..673de491c712 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2692,6 +2718,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string _foo_get_default_response: example: string: @@ -2856,6 +2898,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/FakeApi.md index 356154a4b991..06309f31e8a5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/FakeApi.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Api/FakeApi.cs index bc6276012d1e..82d3054c5a90 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ namespace Org.OpenAPITools.Api /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ namespace Org.OpenAPITools.Api /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Mammal.cs index 39a999e581cb..fdd59ea3787f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Mammal.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..6618a26476f1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..95b561a9f076 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..166feb8ea602 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..6d208f3d9f66 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..313d4f8a5f14 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableShape.cs index 8478eec11933..9387dcff85ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableShape.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Pig.cs index 5363ba83ae71..fda1f010d9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Pig.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Quadrilateral.cs index 13087e6b4549..b3c52fb39dec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Shape.cs index 7cfa900bcf67..a3c9ca29a4be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Shape.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1d618195f4c7..bdf09a757acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Triangle.cs index a410bce92bf2..619915332307 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Triangle.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES index 1e54de3472d2..c6424794961a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/.openapi-generator/FILES @@ -51,7 +51,12 @@ docs/List.md docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -174,7 +179,12 @@ src/Org.OpenAPITools/Model/List.cs src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md index d3de689dee76..ff2b83aeb247 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/README.md @@ -127,6 +127,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -210,7 +212,12 @@ Class | Method | HTTP request | Description - [Model.LiteralStringClass](docs/LiteralStringClass.md) - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml index 1845b502818e..673de491c712 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2692,6 +2718,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string _foo_get_default_response: example: string: @@ -2856,6 +2898,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/FakeApi.md index 788c4017bba8..933fb1c7cad3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/FakeApi.md +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/FakeApi.cs index fda76f972ea2..d2863e79474b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ namespace Org.OpenAPITools.Api /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ namespace Org.OpenAPITools.Api /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Mammal.cs index 39a999e581cb..fdd59ea3787f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Mammal.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..6618a26476f1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..95b561a9f076 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..166feb8ea602 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..6d208f3d9f66 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..313d4f8a5f14 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableShape.cs index 8478eec11933..9387dcff85ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableShape.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pig.cs index 5363ba83ae71..fda1f010d9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Pig.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Quadrilateral.cs index 13087e6b4549..b3c52fb39dec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Shape.cs index 7cfa900bcf67..a3c9ca29a4be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Shape.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1d618195f4c7..bdf09a757acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Triangle.cs index a410bce92bf2..619915332307 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Triangle.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..6e910952f2d2 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Test] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..077e413fd1e6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Test] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Test] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..f60d9c90a978 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Test] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..1970559cf203 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,58 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Test] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..1c58b962a992 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Test] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ae155071cfca --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Test] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Test] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..620602bb3de8 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Test] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Fruit.cs index 97c06633608a..03f2371fcb7f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Fruit.cs @@ -261,11 +261,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/FruitReq.cs index addafd5496c6..9ff316c82338 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/FruitReq.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/GmFruit.cs index 1f9ed867e0a5..6d20d5d8d6cf 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/GmFruit.cs @@ -235,11 +235,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Mammal.cs index cd54b617db3e..19865bd14750 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Mammal.cs @@ -307,11 +307,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..df5cd66f3738 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,118 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this.Content = content; + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedAnyOf); + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf input) + { + if (input == null) + { + return false; + } + return + ( + this.Content == input.Content || + (this.Content != null && + this.Content.Equals(input.Content)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..11a86288d939 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,382 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedAnyOfContent); + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + if (input == null) + return false; + + return this.ActualInstance.Equals(input.ActualInstance); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..e49426f43ddc --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,46 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..1262ffa14505 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,52 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2ef6c97e8f37 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,118 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedOneOf); + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + if (input == null) + { + return false; + } + return + ( + this.Content == input.Content || + (this.Content != null && + this.Content.Equals(input.Content)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..07b45a2ac7e3 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,432 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedOneOfContent); + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + if (input == null) + return false; + + return this.ActualInstance.Equals(input.ActualInstance); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..894e1aa8e13b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,118 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as MixedSubId); + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + (this.Id != null && + this.Id.Equals(input.Id)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableShape.cs index 807f7949c014..2bc6b083fb08 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableShape.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/OneOfString.cs index 9674222ff32d..594bf54530e4 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/OneOfString.cs @@ -215,11 +215,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Pig.cs index 8c02ec73454b..2f94a3d1de24 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Pig.cs @@ -261,11 +261,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 9e4914358c70..d632083ea5e6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -353,11 +353,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Quadrilateral.cs index 4a1c698c2961..232eb3359b3d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -261,11 +261,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Shape.cs index c9e1ea35d53a..59c1774706f9 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Shape.cs @@ -261,11 +261,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2e6187ca57fe..d04647a12a51 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Triangle.cs index 51f2f62bdcfb..2e9eb6ae3947 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Triangle.cs @@ -307,11 +307,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES index 0af518f942ac..23eda3b9d097 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/OpenAPIClient/.openapi-generator/FILES @@ -51,7 +51,12 @@ docs/List.md docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -173,7 +178,12 @@ src/Org.OpenAPITools/Model/List.cs src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.cs diff --git a/samples/client/petstore/csharp/OpenAPIClient/README.md b/samples/client/petstore/csharp/OpenAPIClient/README.md index acb3c3f5664f..f289d00bffcb 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient/README.md @@ -115,6 +115,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -198,7 +200,12 @@ Class | Method | HTTP request | Description - [Model.LiteralStringClass](docs/LiteralStringClass.md) - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.md) diff --git a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml index 1845b502818e..673de491c712 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml +++ b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2692,6 +2718,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string _foo_get_default_response: example: string: @@ -2856,6 +2898,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md b/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md index 356154a4b991..06309f31e8a5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs index 00efbb9d160d..74ecb176bc10 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs @@ -183,5 +183,36 @@ namespace Org.OpenAPITools.Test enumTest.EnumInteger = EnumTest.EnumIntegerEnum.NUMBER_MINUS_1; Assert.Equal("{\"enum_string_required\":0,\"enum_integer\":-1,\"enum_integer_only\":2,\"outerEnum\":null}", JsonConvert.SerializeObject(enumTest)); } + + /// + /// Test AnyOf with different types + /// + [Theory] + [InlineData("{\"content\":\"Hello\"}")] + [InlineData("{\"content\":true}")] + [InlineData("{\"content\":0}")] + [InlineData("{\"content\":0.0}")] + [InlineData("{\"content\":{\"id\":\"id_1234\"}}")] + public void MixedAnyOfRoundTripSerializationTest(string jsonData) + { + var deserializedObj = JsonConvert.DeserializeObject(jsonData); + Assert.Equal(jsonData, JsonConvert.SerializeObject(deserializedObj)); + } + + + /// + /// Test OneOf with different types + /// + [Theory] + [InlineData("{\"content\":\"Hello\"}")] + [InlineData("{\"content\":true}")] + [InlineData("{\"content\":0}")] + [InlineData("{\"content\":0.0}")] + [InlineData("{\"content\":{\"id\":\"id_1234\"}}")] + public void MixedOneOfRoundTripSerializationTest(string jsonData) + { + var deserializedObj = JsonConvert.DeserializeObject(jsonData); + Assert.Equal(jsonData, JsonConvert.SerializeObject(deserializedObj)); + } } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs index bc6276012d1e..82d3054c5a90 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ namespace Org.OpenAPITools.Api /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ namespace Org.OpenAPITools.Api /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Mammal.cs index 39a999e581cb..fdd59ea3787f 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Mammal.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..6618a26476f1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..95b561a9f076 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..166feb8ea602 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..6d208f3d9f66 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..313d4f8a5f14 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,132 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableShape.cs index 8478eec11933..9387dcff85ec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableShape.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Pig.cs index 5363ba83ae71..fda1f010d9ad 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Pig.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Quadrilateral.cs index 13087e6b4549..b3c52fb39dec 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Shape.cs index 7cfa900bcf67..a3c9ca29a4be 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Shape.cs @@ -294,11 +294,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 1d618195f4c7..bdf09a757acc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -303,11 +303,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Triangle.cs index a410bce92bf2..619915332307 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Triangle.cs @@ -343,11 +343,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOf.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedEnumType.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedEnumType.md new file mode 100644 index 000000000000..24385b3ae84f --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedNullableEnumType.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedNullableEnumType.md new file mode 100644 index 000000000000..a38369d002d1 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedNullableEnumType.md @@ -0,0 +1,9 @@ +# Org.OpenAPITools.Model.MixedNullableEnumType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOf.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedSubId.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs new file mode 100644 index 000000000000..5fb0741f597b --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedEnumType + //private MixedEnumType instance; + + public MixedEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedEnumType + //instance = new MixedEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedEnumType + /// + [Fact] + public void MixedEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs new file mode 100644 index 000000000000..c13101dc08f5 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedNullableEnumTypeTests.cs @@ -0,0 +1,57 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedNullableEnumType + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedNullableEnumTypeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedNullableEnumType + //private MixedNullableEnumType instance; + + public MixedNullableEnumTypeTests() + { + // TODO uncomment below to create an instance of MixedNullableEnumType + //instance = new MixedNullableEnumType(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedNullableEnumType + /// + [Fact] + public void MixedNullableEnumTypeInstanceTest() + { + // TODO uncomment below to test "IsType" MixedNullableEnumType + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..24a2a3e2e3b0 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Fruit.cs index bdd22a90f800..5441a63ab707 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Fruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Fruit.cs @@ -270,11 +270,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Fruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Fruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/FruitReq.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/FruitReq.cs index 7d64b10bf22f..08e3b38bc378 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/FruitReq.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/FruitReq.cs @@ -279,11 +279,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return FruitReq.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return FruitReq.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs index 9d97bc6177fc..9907589d7074 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/GmFruit.cs @@ -243,11 +243,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return GmFruit.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return GmFruit.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Mammal.cs index 3b56322b35ac..7ad628d2395d 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Mammal.cs @@ -317,11 +317,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Mammal.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Mammal.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..f6680350498c --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,120 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this.Content = content; + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOf).AreEqual; + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedEnumType.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedEnumType.cs new file mode 100644 index 000000000000..95b561a9f076 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedEnumType.cs @@ -0,0 +1,48 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedEnumType + { + /// + /// Enum SOMETHING for value: SOMETHING + /// + [EnumMember(Value = "SOMETHING")] + SOMETHING = 1, + + /// + /// Enum OTHER for value: OTHER + /// + [EnumMember(Value = "OTHER")] + OTHER = 2 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs new file mode 100644 index 000000000000..166feb8ea602 --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedNullableEnumType.cs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Defines MixedNullableEnumType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MixedNullableEnumType + { + /// + /// Enum SOMETHINGNULL for value: SOMETHING_NULL + /// + [EnumMember(Value = "SOMETHING_NULL")] + SOMETHINGNULL = 1, + + /// + /// Enum SOMETHINGNEWED for value: SOMETHING_NEWED + /// + [EnumMember(Value = "SOMETHING_NEWED")] + SOMETHINGNEWED = 2, + + /// + /// Enum Null for value: null + /// + [EnumMember(Value = "null")] + Null = 3 + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..91a4a75726bd --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,120 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this.Content = content; + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Content != null) + { + hashCode = (hashCode * 59) + this.Content.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..629e16dab53a --- /dev/null +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,120 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this.Id = id; + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Id != null) + { + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableShape.cs index 98ccce0a310e..404fd0328dc2 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -280,11 +280,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return NullableShape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return NullableShape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/OneOfString.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/OneOfString.cs index d64b1764a338..b9b38efe7d20 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/OneOfString.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/OneOfString.cs @@ -224,11 +224,17 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.String: + return new OneOfString(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return OneOfString.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return OneOfString.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pig.cs index a4545d17dc97..d0a1b2d1423b 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Pig.cs @@ -271,11 +271,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Pig.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Pig.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs index 1c09e9ad20d5..813b60a703f0 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/PolymorphicProperty.cs @@ -362,11 +362,19 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.Boolean: + return new PolymorphicProperty(Convert.ToBoolean(reader.Value)); + case JsonToken.String: + return new PolymorphicProperty(Convert.ToString(reader.Value)); + case JsonToken.StartObject: + return PolymorphicProperty.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return PolymorphicProperty.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Quadrilateral.cs index 8aeb2202fe63..30cd6dbcde35 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -271,11 +271,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Quadrilateral.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Quadrilateral.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Shape.cs index 987bf4fc3397..5451b271ad85 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Shape.cs @@ -271,11 +271,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Shape.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Shape.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index b70fe7266740..ec7d3c7aec85 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -280,11 +280,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return ShapeOrNull.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return ShapeOrNull.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } /// diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Triangle.cs index 02d2aa99fcd6..482c52b104c5 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Triangle.cs @@ -317,11 +317,15 @@ namespace Org.OpenAPITools.Model /// The object converted from the JSON string public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.TokenType != JsonToken.Null) + switch(reader.TokenType) { - return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartObject: + return Triangle.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return Triangle.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; } - return null; } ///