Fix bug in ModelUtils.getParentName resulting in wrong inner Models for oneOf-composed schemas (#21799)

* Test Cases for more than two oneOf-Options (both passing, but important to narrow down observed bug)

* fix language-specific tests broken by adding a third fruit to oneOf test

* create reproducer unit test for java client codegen

* fix typo in test yaml

* fix ModelUtils.getParentName returning name of first element in composed schema instead of null when there are multiple elements and it is not clear which one should be parent

* rename test yaml and added tests for clarity

* update samples

* update samples again
This commit is contained in:
fkellner
2025-09-02 09:26:26 +02:00
committed by GitHub
parent c854a23682
commit efd06f5719
97 changed files with 1593 additions and 34 deletions

View File

@@ -1573,6 +1573,7 @@ public class ModelUtils {
List<String> refedWithoutDiscriminator = new ArrayList<>(); List<String> refedWithoutDiscriminator = new ArrayList<>();
if (interfaces != null && !interfaces.isEmpty()) { if (interfaces != null && !interfaces.isEmpty()) {
List<String> parentNameCandidates = new ArrayList<>(interfaces.size());
for (Schema schema : interfaces) { for (Schema schema : interfaces) {
// get the actual schema // get the actual schema
if (StringUtils.isNotEmpty(schema.get$ref())) { if (StringUtils.isNotEmpty(schema.get$ref())) {
@@ -1580,10 +1581,10 @@ public class ModelUtils {
Schema s = allSchemas.get(parentName); Schema s = allSchemas.get(parentName);
if (s == null) { if (s == null) {
LOGGER.error("Failed to obtain schema from {}", parentName); LOGGER.error("Failed to obtain schema from {}", parentName);
return "UNKNOWN_PARENT_NAME"; parentNameCandidates.add("UNKNOWN_PARENT_NAME");
} else if (hasOrInheritsDiscriminator(s, allSchemas, new ArrayList<Schema>())) { } else if (hasOrInheritsDiscriminator(s, allSchemas, new ArrayList<Schema>())) {
// discriminator.propertyName is used or x-parent is used // discriminator.propertyName is used or x-parent is used
return parentName; parentNameCandidates.add(parentName);
} else { } else {
// not a parent since discriminator.propertyName or x-parent is not set // not a parent since discriminator.propertyName or x-parent is not set
hasAmbiguousParents = true; hasAmbiguousParents = true;
@@ -1600,6 +1601,12 @@ public class ModelUtils {
} }
} }
} }
if (parentNameCandidates.size() > 1) {
// unclear which one should be the parent
return null;
} else if (parentNameCandidates.size() == 1) {
return parentNameCandidates.get(0);
}
if (refedWithoutDiscriminator.size() == 1 && nullSchemaChildrenCount == 1) { if (refedWithoutDiscriminator.size() == 1 && nullSchemaChildrenCount == 1) {
// One schema is a $ref and the other is the 'null' type, so the parent is obvious. // One schema is a $ref and the other is the 'null' type, so the parent is obvious.
// In this particular case there is no need to specify a discriminator. // In this particular case there is no need to specify a discriminator.

View File

@@ -766,9 +766,10 @@ public class DefaultCodegenTest {
Set<String> oneOf = new TreeSet<>(); Set<String> oneOf = new TreeSet<>();
oneOf.add("Apple"); oneOf.add("Apple");
oneOf.add("Banana"); oneOf.add("Banana");
oneOf.add("Orange");
assertEquals(fruit.oneOf, oneOf); assertEquals(fruit.oneOf, oneOf);
assertEquals(3, fruit.optionalVars.size()); assertEquals(4, fruit.optionalVars.size());
assertEquals(3, fruit.vars.size()); assertEquals(4, fruit.vars.size());
// make sure that fruit has the property color // make sure that fruit has the property color
boolean colorSeen = false; boolean colorSeen = false;
for (CodegenProperty cp : fruit.vars) { for (CodegenProperty cp : fruit.vars) {
@@ -788,6 +789,32 @@ public class DefaultCodegenTest {
assertTrue(colorSeen); assertTrue(colorSeen);
} }
@Test
public void testComposedSchemaOneOfWithInnerModel() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/oneOf_innerModel.yaml");
final DefaultCodegen codegen = new DefaultCodegen();
final Schema schema = openAPI.getComponents().getSchemas().get("RandomAnimalsResponse_animals_inner");
codegen.setOpenAPI(openAPI);
CodegenModel randomAnimalsResponseInner = codegen.fromModel("RandomAnimalsResponse_animals_inner", schema);
Set<String> oneOf = new TreeSet<>();
oneOf.add("Mouse");
oneOf.add("Cat");
oneOf.add("Dog");
assertEquals(oneOf, randomAnimalsResponseInner.oneOf);
assertEquals(4, randomAnimalsResponseInner.vars.size());
// make sure that RandomAnimalsResponseInner has the property species
boolean speciesSeen = false;
for (CodegenProperty cp : randomAnimalsResponseInner.vars) {
if ("species".equals(cp.name)) {
speciesSeen = true;
break;
}
}
assertTrue(speciesSeen);
}
@Test @Test
public void testEscapeText() { public void testEscapeText() {
final DefaultCodegen codegen = new DefaultCodegen(); final DefaultCodegen codegen = new DefaultCodegen();

View File

@@ -40,12 +40,14 @@ import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.java.assertions.JavaFileAssert; import org.openapitools.codegen.java.assertions.JavaFileAssert;
import org.openapitools.codegen.languages.AbstractJavaCodegen; import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.languages.JavaClientCodegen; import org.openapitools.codegen.languages.JavaClientCodegen;
import org.openapitools.codegen.languages.RubyClientCodegen;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.CXFServerFeatures; import org.openapitools.codegen.languages.features.CXFServerFeatures;
import org.openapitools.codegen.meta.features.SecurityFeature; import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap; import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.testutils.ConfigAssert; import org.openapitools.codegen.testutils.ConfigAssert;
import org.testng.Assert;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters; import org.testng.annotations.Parameters;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -67,6 +69,8 @@ import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry; import static org.assertj.core.api.Assertions.entry;
import static org.assertj.core.api.InstanceOfAssertFactories.FILE; import static org.assertj.core.api.InstanceOfAssertFactories.FILE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openapitools.codegen.CodegenConstants.*; import static org.openapitools.codegen.CodegenConstants.*;
import static org.openapitools.codegen.TestUtils.*; import static org.openapitools.codegen.TestUtils.*;
import static org.openapitools.codegen.languages.JavaClientCodegen.*; import static org.openapitools.codegen.languages.JavaClientCodegen.*;
@@ -3837,4 +3841,49 @@ public class JavaClientCodegenTest {
public static Object[] springClients() { public static Object[] springClients() {
return new Object[]{RESTCLIENT, WEBCLIENT}; return new Object[]{RESTCLIENT, WEBCLIENT};
} }
@Test(description = "test oneOf (OAS3)")
public void oneOfTest() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/oneOf.yaml");
final JavaClientCodegen codegen = new JavaClientCodegen();
final Schema schema = openAPI.getComponents().getSchemas().get("fruit");
codegen.setOpenAPI(openAPI);
CodegenModel fruit = codegen.fromModel("Fruit", schema);
Set<String> oneOf = new TreeSet<String>();
oneOf.add("Apple");
oneOf.add("Banana");
oneOf.add("Orange");
Assert.assertEquals(fruit.oneOf, oneOf);
assertEquals(4, fruit.optionalVars.size());
assertEquals(4, fruit.vars.size());
}
@Test
public void oneOfWithInnerModelTest() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/oneOf_innerModel.yaml");
final JavaClientCodegen codegen = new JavaClientCodegen();
final Schema schema = openAPI.getComponents().getSchemas().get("RandomAnimalsResponse_animals_inner");
codegen.setOpenAPI(openAPI);
CodegenModel randomAnimalsResponseInner = codegen.fromModel("RandomAnimalsResponse_animals_inner", schema);
Set<String> oneOf = new TreeSet<>();
oneOf.add("Mouse");
oneOf.add("Cat");
oneOf.add("Dog");
assertEquals(oneOf, randomAnimalsResponseInner.oneOf);
assertEquals(4, randomAnimalsResponseInner.vars.size());
// make sure that RandomAnimalsResponseInner has the property species
boolean speciesSeen = false;
for (CodegenProperty cp : randomAnimalsResponseInner.vars) {
if ("species".equals(cp.name)) {
speciesSeen = true;
break;
}
}
assertTrue(speciesSeen);
}
} }

View File

@@ -368,6 +368,7 @@ public class RubyClientCodegenTest {
Set<String> oneOf = new TreeSet<String>(); Set<String> oneOf = new TreeSet<String>();
oneOf.add("Apple"); oneOf.add("Apple");
oneOf.add("Banana"); oneOf.add("Banana");
oneOf.add("Orange");
Assert.assertEquals(fruit.oneOf, oneOf); Assert.assertEquals(fruit.oneOf, oneOf);
} }

View File

@@ -675,4 +675,12 @@ public class ModelUtilsTest {
testSchema.setAdditionalProperties(new Schema().type("string")); testSchema.setAdditionalProperties(new Schema().type("string"));
assertFalse(ModelUtils.isModelWithPropertiesOnly(testSchema)); assertFalse(ModelUtils.isModelWithPropertiesOnly(testSchema));
} }
@Test
public void getParentNameMultipleInterfacesTest() {
OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/oneOf_innerModel.yaml");
Map<String, Schema> allSchemas = openAPI.getComponents().getSchemas();
Schema composedSchema = allSchemas.get("RandomAnimalsResponse_animals_inner");
assertNull(ModelUtils.getParentName(composedSchema, allSchemas));
}
} }

View File

@@ -22,6 +22,7 @@ components:
oneOf: oneOf:
- $ref: '#/components/schemas/apple' - $ref: '#/components/schemas/apple'
- $ref: '#/components/schemas/banana' - $ref: '#/components/schemas/banana'
- $ref: '#/components/schemas/orange'
# additionalProperties: # additionalProperties:
# type: string # type: string
# uncomment this when https://github.com/swagger-api/swagger-parser/issues/1252 is resolved # uncomment this when https://github.com/swagger-api/swagger-parser/issues/1252 is resolved
@@ -37,3 +38,9 @@ components:
properties: properties:
count: count:
type: number type: number
orange:
title: orange
type: object
properties:
sweet:
type: boolean

View File

@@ -0,0 +1,70 @@
---
openapi: 3.0.3
info:
title: randimals
version: "1.0"
paths:
/random-animals:
get:
tags:
- Random Animals Resource
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/RandomAnimalsResponse'
components:
schemas:
RandomAnimalsResponse:
type: object
properties:
animals:
type: array
items:
oneOf:
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Mouse'
required:
- animals
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
dogId:
type: string
required:
- dogId
Animal:
discriminator:
propertyName: species
mapping:
Dog: '#/components/schemas/Dog'
Cat: '#/components/schemas/Cat'
Mouse: '#/components/schemas/Mouse'
properties:
species:
type: string
required:
- species
Cat:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
catId:
type: string
required:
- catId
Mouse:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
mouseId:
type: string
required:
- mouseId

View File

@@ -14,14 +14,13 @@ package openapitools;
import public "models/apple.proto"; import public "models/apple.proto";
import public "models/banana.proto"; import public "models/banana.proto";
import public "models/orange.proto";
message Fruit { message Fruit {
oneof fruit { oneof fruit {
Apple apple = 93029210; Apple apple = 93029210;
Banana banana = 322613405; Banana banana = 322613405;
Orange orange = 471980499;
} }
} }

View File

@@ -7,6 +7,7 @@ docs/apis/DefaultApi.md
docs/models/Apple.md docs/models/Apple.md
docs/models/Banana.md docs/models/Banana.md
docs/models/Fruit.md docs/models/Fruit.md
docs/models/Orange.md
docs/scripts/git_push.ps1 docs/scripts/git_push.ps1
docs/scripts/git_push.sh docs/scripts/git_push.sh
src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs
@@ -36,5 +37,6 @@ src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs
src/Org.OpenAPITools/Model/Apple.cs src/Org.OpenAPITools/Model/Apple.cs
src/Org.OpenAPITools/Model/Banana.cs src/Org.OpenAPITools/Model/Banana.cs
src/Org.OpenAPITools/Model/Fruit.cs src/Org.OpenAPITools/Model/Fruit.cs
src/Org.OpenAPITools/Model/Orange.cs
src/Org.OpenAPITools/Org.OpenAPITools.csproj src/Org.OpenAPITools/Org.OpenAPITools.csproj
src/Org.OpenAPITools/README.md src/Org.OpenAPITools/README.md

View File

@@ -22,6 +22,7 @@ components:
oneOf: oneOf:
- $ref: "#/components/schemas/apple" - $ref: "#/components/schemas/apple"
- $ref: "#/components/schemas/banana" - $ref: "#/components/schemas/banana"
- $ref: "#/components/schemas/orange"
properties: properties:
color: color:
type: string type: string
@@ -38,4 +39,10 @@ components:
type: number type: number
title: banana title: banana
type: object type: object
orange:
properties:
sweet:
type: boolean
title: orange
type: object

View File

@@ -0,0 +1,10 @@
# Org.OpenAPITools.Model.Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Sweet** | **bool** | | [optional]
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,65 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing Orange
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class OrangeTests : IDisposable
{
// TODO uncomment below to declare an instance variable for Orange
//private Orange instance;
public OrangeTests()
{
// TODO uncomment below to create an instance of Orange
//instance = new Orange();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of Orange
/// </summary>
[Fact]
public void OrangeInstanceTest()
{
// TODO uncomment below to test "IsType" Orange
//Assert.IsType<Orange>(instance);
}
/// <summary>
/// Test the property 'Sweet'
/// </summary>
[Fact]
public void SweetTest()
{
// TODO unit test for the property 'Sweet'
}
}
}

View File

@@ -42,6 +42,7 @@ namespace Org.OpenAPITools.Client
_jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new AppleJsonConverter());
_jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter());
_jsonOptions.Converters.Add(new FruitJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter());
_jsonOptions.Converters.Add(new OrangeJsonConverter());
JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(jsonSerializerOptionsProvider);
_services.AddSingleton<IApiFactory, ApiFactory>(); _services.AddSingleton<IApiFactory, ApiFactory>();

View File

@@ -53,6 +53,18 @@ namespace Org.OpenAPITools.Model
OnCreated(); OnCreated();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Fruit" /> class.
/// </summary>
/// <param name="orange"></param>
/// <param name="color">color</param>
public Fruit(Orange orange, Option<string> color = default)
{
Orange = orange;
ColorOption = color;
OnCreated();
}
partial void OnCreated(); partial void OnCreated();
/// <summary> /// <summary>
@@ -65,6 +77,11 @@ namespace Org.OpenAPITools.Model
/// </summary> /// </summary>
public Banana Banana { get; set; } public Banana Banana { get; set; }
/// <summary>
/// Gets or Sets Orange
/// </summary>
public Orange Orange { get; set; }
/// <summary> /// <summary>
/// Used to track the state of Color /// Used to track the state of Color
/// </summary> /// </summary>
@@ -135,6 +152,7 @@ namespace Org.OpenAPITools.Model
Apple apple = default; Apple apple = default;
Banana banana = default; Banana banana = default;
Orange orange = default;
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
while (utf8JsonReaderOneOf.Read()) while (utf8JsonReaderOneOf.Read())
@@ -152,6 +170,9 @@ namespace Org.OpenAPITools.Model
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
ClientUtils.TryDeserialize<Banana>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); ClientUtils.TryDeserialize<Banana>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
Utf8JsonReader utf8JsonReaderOrange = utf8JsonReader;
ClientUtils.TryDeserialize<Orange>(ref utf8JsonReaderOrange, jsonSerializerOptions, out orange);
} }
} }
@@ -188,6 +209,9 @@ namespace Org.OpenAPITools.Model
if (banana != null) if (banana != null)
return new Fruit(banana, color); return new Fruit(banana, color);
if (orange != null)
return new Fruit(orange, color);
throw new JsonException(); throw new JsonException();
} }

View File

@@ -0,0 +1,171 @@
// <auto-generated>
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
using Org.OpenAPITools.Client;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// Orange
/// </summary>
public partial class Orange : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Orange" /> class.
/// </summary>
/// <param name="sweet">sweet</param>
[JsonConstructor]
public Orange(Option<bool?> sweet = default)
{
SweetOption = sweet;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Sweet
/// </summary>
[JsonIgnore]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> SweetOption { get; private set; }
/// <summary>
/// Gets or Sets Sweet
/// </summary>
[JsonPropertyName("sweet")]
public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new Option<bool?>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class Orange {\n");
sb.Append(" Sweet: ").Append(Sweet).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="Orange" />
/// </summary>
public class OrangeJsonConverter : JsonConverter<Orange>
{
/// <summary>
/// Deserializes json to <see cref="Orange" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
Option<bool?> sweet = default;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
switch (localVarJsonPropertyName)
{
case "sweet":
sweet = new Option<bool?>(utf8JsonReader.TokenType == JsonTokenType.Null ? (bool?)null : utf8JsonReader.GetBoolean());
break;
default:
break;
}
}
}
if (sweet.IsSet && sweet.Value == null)
throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
return new Orange(sweet);
}
/// <summary>
/// Serializes a <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, orange, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value.Value);
}
}
}

View File

@@ -7,6 +7,7 @@ docs/apis/DefaultApi.md
docs/models/Apple.md docs/models/Apple.md
docs/models/Banana.md docs/models/Banana.md
docs/models/Fruit.md docs/models/Fruit.md
docs/models/Orange.md
docs/scripts/git_push.ps1 docs/scripts/git_push.ps1
docs/scripts/git_push.sh docs/scripts/git_push.sh
src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs
@@ -36,5 +37,6 @@ src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs
src/Org.OpenAPITools/Model/Apple.cs src/Org.OpenAPITools/Model/Apple.cs
src/Org.OpenAPITools/Model/Banana.cs src/Org.OpenAPITools/Model/Banana.cs
src/Org.OpenAPITools/Model/Fruit.cs src/Org.OpenAPITools/Model/Fruit.cs
src/Org.OpenAPITools/Model/Orange.cs
src/Org.OpenAPITools/Org.OpenAPITools.csproj src/Org.OpenAPITools/Org.OpenAPITools.csproj
src/Org.OpenAPITools/README.md src/Org.OpenAPITools/README.md

View File

@@ -22,6 +22,7 @@ components:
oneOf: oneOf:
- $ref: "#/components/schemas/apple" - $ref: "#/components/schemas/apple"
- $ref: "#/components/schemas/banana" - $ref: "#/components/schemas/banana"
- $ref: "#/components/schemas/orange"
properties: properties:
color: color:
type: string type: string
@@ -38,4 +39,10 @@ components:
type: number type: number
title: banana title: banana
type: object type: object
orange:
properties:
sweet:
type: boolean
title: orange
type: object

View File

@@ -0,0 +1,10 @@
# Org.OpenAPITools.Model.Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Sweet** | **bool** | | [optional]
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,65 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing Orange
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class OrangeTests : IDisposable
{
// TODO uncomment below to declare an instance variable for Orange
//private Orange instance;
public OrangeTests()
{
// TODO uncomment below to create an instance of Orange
//instance = new Orange();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of Orange
/// </summary>
[Fact]
public void OrangeInstanceTest()
{
// TODO uncomment below to test "IsType" Orange
//Assert.IsType<Orange>(instance);
}
/// <summary>
/// Test the property 'Sweet'
/// </summary>
[Fact]
public void SweetTest()
{
// TODO unit test for the property 'Sweet'
}
}
}

View File

@@ -42,6 +42,7 @@ namespace Org.OpenAPITools.Client
_jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new AppleJsonConverter());
_jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter());
_jsonOptions.Converters.Add(new FruitJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter());
_jsonOptions.Converters.Add(new OrangeJsonConverter());
JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions); JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new JsonSerializerOptionsProvider(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(jsonSerializerOptionsProvider);
_services.AddSingleton<IApiFactory, ApiFactory>(); _services.AddSingleton<IApiFactory, ApiFactory>();

View File

@@ -53,6 +53,18 @@ namespace Org.OpenAPITools.Model
OnCreated(); OnCreated();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Fruit" /> class.
/// </summary>
/// <param name="orange"></param>
/// <param name="color">color</param>
public Fruit(Orange orange, Option<string> color = default)
{
Orange = orange;
ColorOption = color;
OnCreated();
}
partial void OnCreated(); partial void OnCreated();
/// <summary> /// <summary>
@@ -65,6 +77,11 @@ namespace Org.OpenAPITools.Model
/// </summary> /// </summary>
public Banana Banana { get; set; } public Banana Banana { get; set; }
/// <summary>
/// Gets or Sets Orange
/// </summary>
public Orange Orange { get; set; }
/// <summary> /// <summary>
/// Used to track the state of Color /// Used to track the state of Color
/// </summary> /// </summary>
@@ -135,6 +152,7 @@ namespace Org.OpenAPITools.Model
Apple apple = default; Apple apple = default;
Banana banana = default; Banana banana = default;
Orange orange = default;
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
while (utf8JsonReaderOneOf.Read()) while (utf8JsonReaderOneOf.Read())
@@ -152,6 +170,9 @@ namespace Org.OpenAPITools.Model
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
ClientUtils.TryDeserialize<Banana>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); ClientUtils.TryDeserialize<Banana>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
Utf8JsonReader utf8JsonReaderOrange = utf8JsonReader;
ClientUtils.TryDeserialize<Orange>(ref utf8JsonReaderOrange, jsonSerializerOptions, out orange);
} }
} }
@@ -188,6 +209,9 @@ namespace Org.OpenAPITools.Model
if (banana != null) if (banana != null)
return new Fruit(banana, color); return new Fruit(banana, color);
if (orange != null)
return new Fruit(orange, color);
throw new JsonException(); throw new JsonException();
} }

View File

@@ -0,0 +1,171 @@
// <auto-generated>
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
using Org.OpenAPITools.Client;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// Orange
/// </summary>
public partial class Orange : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Orange" /> class.
/// </summary>
/// <param name="sweet">sweet</param>
[JsonConstructor]
public Orange(Option<bool?> sweet = default)
{
SweetOption = sweet;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Sweet
/// </summary>
[JsonIgnore]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> SweetOption { get; private set; }
/// <summary>
/// Gets or Sets Sweet
/// </summary>
[JsonPropertyName("sweet")]
public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new Option<bool?>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class Orange {\n");
sb.Append(" Sweet: ").Append(Sweet).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="Orange" />
/// </summary>
public class OrangeJsonConverter : JsonConverter<Orange>
{
/// <summary>
/// Deserializes json to <see cref="Orange" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
Option<bool?> sweet = default;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
switch (localVarJsonPropertyName)
{
case "sweet":
sweet = new Option<bool?>(utf8JsonReader.TokenType == JsonTokenType.Null ? (bool?)null : utf8JsonReader.GetBoolean());
break;
default:
break;
}
}
}
if (sweet.IsSet && sweet.Value == null)
throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
return new Orange(sweet);
}
/// <summary>
/// Serializes a <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, orange, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value.Value);
}
}
}

View File

@@ -7,6 +7,7 @@ docs/apis/DefaultApi.md
docs/models/Apple.md docs/models/Apple.md
docs/models/Banana.md docs/models/Banana.md
docs/models/Fruit.md docs/models/Fruit.md
docs/models/Orange.md
docs/scripts/git_push.ps1 docs/scripts/git_push.ps1
docs/scripts/git_push.sh docs/scripts/git_push.sh
src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs
@@ -38,5 +39,6 @@ src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs
src/Org.OpenAPITools/Model/Apple.cs src/Org.OpenAPITools/Model/Apple.cs
src/Org.OpenAPITools/Model/Banana.cs src/Org.OpenAPITools/Model/Banana.cs
src/Org.OpenAPITools/Model/Fruit.cs src/Org.OpenAPITools/Model/Fruit.cs
src/Org.OpenAPITools/Model/Orange.cs
src/Org.OpenAPITools/Org.OpenAPITools.csproj src/Org.OpenAPITools/Org.OpenAPITools.csproj
src/Org.OpenAPITools/README.md src/Org.OpenAPITools/README.md

View File

@@ -22,6 +22,7 @@ components:
oneOf: oneOf:
- $ref: "#/components/schemas/apple" - $ref: "#/components/schemas/apple"
- $ref: "#/components/schemas/banana" - $ref: "#/components/schemas/banana"
- $ref: "#/components/schemas/orange"
properties: properties:
color: color:
type: string type: string
@@ -38,4 +39,10 @@ components:
type: number type: number
title: banana title: banana
type: object type: object
orange:
properties:
sweet:
type: boolean
title: orange
type: object

View File

@@ -0,0 +1,10 @@
# Org.OpenAPITools.Model.Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Sweet** | **bool** | | [optional]
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,65 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing Orange
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class OrangeTests : IDisposable
{
// TODO uncomment below to declare an instance variable for Orange
//private Orange instance;
public OrangeTests()
{
// TODO uncomment below to create an instance of Orange
//instance = new Orange();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of Orange
/// </summary>
[Fact]
public void OrangeInstanceTest()
{
// TODO uncomment below to test "IsType" Orange
//Assert.IsType<Orange>(instance);
}
/// <summary>
/// Test the property 'Sweet'
/// </summary>
[Fact]
public void SweetTest()
{
// TODO unit test for the property 'Sweet'
}
}
}

View File

@@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Client
_jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new AppleJsonConverter());
_jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter());
_jsonOptions.Converters.Add(new FruitJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter());
_jsonOptions.Converters.Add(new OrangeJsonConverter());
JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(jsonSerializerOptionsProvider);
_services.AddSingleton<IApiFactory, ApiFactory>(); _services.AddSingleton<IApiFactory, ApiFactory>();

View File

@@ -55,6 +55,18 @@ namespace Org.OpenAPITools.Model
OnCreated(); OnCreated();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Fruit" /> class.
/// </summary>
/// <param name="orange"></param>
/// <param name="color">color</param>
public Fruit(Orange orange, Option<string?> color = default)
{
Orange = orange;
ColorOption = color;
OnCreated();
}
partial void OnCreated(); partial void OnCreated();
/// <summary> /// <summary>
@@ -67,6 +79,11 @@ namespace Org.OpenAPITools.Model
/// </summary> /// </summary>
public Banana? Banana { get; set; } public Banana? Banana { get; set; }
/// <summary>
/// Gets or Sets Orange
/// </summary>
public Orange? Orange { get; set; }
/// <summary> /// <summary>
/// Used to track the state of Color /// Used to track the state of Color
/// </summary> /// </summary>
@@ -137,6 +154,7 @@ namespace Org.OpenAPITools.Model
Apple? apple = default; Apple? apple = default;
Banana? banana = default; Banana? banana = default;
Orange? orange = default;
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
while (utf8JsonReaderOneOf.Read()) while (utf8JsonReaderOneOf.Read())
@@ -154,6 +172,9 @@ namespace Org.OpenAPITools.Model
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
ClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); ClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
Utf8JsonReader utf8JsonReaderOrange = utf8JsonReader;
ClientUtils.TryDeserialize<Orange?>(ref utf8JsonReaderOrange, jsonSerializerOptions, out orange);
} }
} }
@@ -190,6 +211,9 @@ namespace Org.OpenAPITools.Model
if (banana != null) if (banana != null)
return new Fruit(banana, color); return new Fruit(banana, color);
if (orange != null)
return new Fruit(orange, color);
throw new JsonException(); throw new JsonException();
} }

View File

@@ -0,0 +1,173 @@
// <auto-generated>
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
using Org.OpenAPITools.Client;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// Orange
/// </summary>
public partial class Orange : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Orange" /> class.
/// </summary>
/// <param name="sweet">sweet</param>
[JsonConstructor]
public Orange(Option<bool?> sweet = default)
{
SweetOption = sweet;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Sweet
/// </summary>
[JsonIgnore]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> SweetOption { get; private set; }
/// <summary>
/// Gets or Sets Sweet
/// </summary>
[JsonPropertyName("sweet")]
public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class Orange {\n");
sb.Append(" Sweet: ").Append(Sweet).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="Orange" />
/// </summary>
public class OrangeJsonConverter : JsonConverter<Orange>
{
/// <summary>
/// Deserializes json to <see cref="Orange" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
Option<bool?> sweet = default;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
switch (localVarJsonPropertyName)
{
case "sweet":
sweet = new Option<bool?>(utf8JsonReader.TokenType == JsonTokenType.Null ? (bool?)null : utf8JsonReader.GetBoolean());
break;
default:
break;
}
}
}
if (sweet.IsSet && sweet.Value == null)
throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
return new Orange(sweet);
}
/// <summary>
/// Serializes a <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, orange, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
}
}
}

View File

@@ -7,6 +7,7 @@ docs/apis/DefaultApi.md
docs/models/Apple.md docs/models/Apple.md
docs/models/Banana.md docs/models/Banana.md
docs/models/Fruit.md docs/models/Fruit.md
docs/models/Orange.md
docs/scripts/git_push.ps1 docs/scripts/git_push.ps1
docs/scripts/git_push.sh docs/scripts/git_push.sh
src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs
@@ -38,5 +39,6 @@ src/Org.OpenAPITools/Extensions/IServiceCollectionExtensions.cs
src/Org.OpenAPITools/Model/Apple.cs src/Org.OpenAPITools/Model/Apple.cs
src/Org.OpenAPITools/Model/Banana.cs src/Org.OpenAPITools/Model/Banana.cs
src/Org.OpenAPITools/Model/Fruit.cs src/Org.OpenAPITools/Model/Fruit.cs
src/Org.OpenAPITools/Model/Orange.cs
src/Org.OpenAPITools/Org.OpenAPITools.csproj src/Org.OpenAPITools/Org.OpenAPITools.csproj
src/Org.OpenAPITools/README.md src/Org.OpenAPITools/README.md

View File

@@ -22,6 +22,7 @@ components:
oneOf: oneOf:
- $ref: "#/components/schemas/apple" - $ref: "#/components/schemas/apple"
- $ref: "#/components/schemas/banana" - $ref: "#/components/schemas/banana"
- $ref: "#/components/schemas/orange"
properties: properties:
color: color:
type: string type: string
@@ -38,4 +39,10 @@ components:
type: number type: number
title: banana title: banana
type: object type: object
orange:
properties:
sweet:
type: boolean
title: orange
type: object

View File

@@ -0,0 +1,10 @@
# Org.OpenAPITools.Model.Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Sweet** | **bool** | | [optional]
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,65 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using Xunit;
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Org.OpenAPITools.Model;
using Org.OpenAPITools.Client;
using System.Reflection;
namespace Org.OpenAPITools.Test.Model
{
/// <summary>
/// Class for testing Orange
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class OrangeTests : IDisposable
{
// TODO uncomment below to declare an instance variable for Orange
//private Orange instance;
public OrangeTests()
{
// TODO uncomment below to create an instance of Orange
//instance = new Orange();
}
public void Dispose()
{
// Cleanup when everything is done.
}
/// <summary>
/// Test an instance of Orange
/// </summary>
[Fact]
public void OrangeInstanceTest()
{
// TODO uncomment below to test "IsType" Orange
//Assert.IsType<Orange>(instance);
}
/// <summary>
/// Test the property 'Sweet'
/// </summary>
[Fact]
public void SweetTest()
{
// TODO unit test for the property 'Sweet'
}
}
}

View File

@@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Client
_jsonOptions.Converters.Add(new AppleJsonConverter()); _jsonOptions.Converters.Add(new AppleJsonConverter());
_jsonOptions.Converters.Add(new BananaJsonConverter()); _jsonOptions.Converters.Add(new BananaJsonConverter());
_jsonOptions.Converters.Add(new FruitJsonConverter()); _jsonOptions.Converters.Add(new FruitJsonConverter());
_jsonOptions.Converters.Add(new OrangeJsonConverter());
JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions); JsonSerializerOptionsProvider jsonSerializerOptionsProvider = new(_jsonOptions);
_services.AddSingleton(jsonSerializerOptionsProvider); _services.AddSingleton(jsonSerializerOptionsProvider);
_services.AddSingleton<IApiFactory, ApiFactory>(); _services.AddSingleton<IApiFactory, ApiFactory>();

View File

@@ -55,6 +55,18 @@ namespace Org.OpenAPITools.Model
OnCreated(); OnCreated();
} }
/// <summary>
/// Initializes a new instance of the <see cref="Fruit" /> class.
/// </summary>
/// <param name="orange"></param>
/// <param name="color">color</param>
public Fruit(Orange orange, Option<string?> color = default)
{
Orange = orange;
ColorOption = color;
OnCreated();
}
partial void OnCreated(); partial void OnCreated();
/// <summary> /// <summary>
@@ -67,6 +79,11 @@ namespace Org.OpenAPITools.Model
/// </summary> /// </summary>
public Banana? Banana { get; set; } public Banana? Banana { get; set; }
/// <summary>
/// Gets or Sets Orange
/// </summary>
public Orange? Orange { get; set; }
/// <summary> /// <summary>
/// Used to track the state of Color /// Used to track the state of Color
/// </summary> /// </summary>
@@ -137,6 +154,7 @@ namespace Org.OpenAPITools.Model
Apple? apple = default; Apple? apple = default;
Banana? banana = default; Banana? banana = default;
Orange? orange = default;
Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader;
while (utf8JsonReaderOneOf.Read()) while (utf8JsonReaderOneOf.Read())
@@ -154,6 +172,9 @@ namespace Org.OpenAPITools.Model
Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader; Utf8JsonReader utf8JsonReaderBanana = utf8JsonReader;
ClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana); ClientUtils.TryDeserialize<Banana?>(ref utf8JsonReaderBanana, jsonSerializerOptions, out banana);
Utf8JsonReader utf8JsonReaderOrange = utf8JsonReader;
ClientUtils.TryDeserialize<Orange?>(ref utf8JsonReaderOrange, jsonSerializerOptions, out orange);
} }
} }
@@ -190,6 +211,9 @@ namespace Org.OpenAPITools.Model
if (banana != null) if (banana != null)
return new Fruit(banana, color); return new Fruit(banana, color);
if (orange != null)
return new Fruit(orange, color);
throw new JsonException(); throw new JsonException();
} }

View File

@@ -0,0 +1,173 @@
// <auto-generated>
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
using Org.OpenAPITools.Client;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// Orange
/// </summary>
public partial class Orange : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Orange" /> class.
/// </summary>
/// <param name="sweet">sweet</param>
[JsonConstructor]
public Orange(Option<bool?> sweet = default)
{
SweetOption = sweet;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Sweet
/// </summary>
[JsonIgnore]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> SweetOption { get; private set; }
/// <summary>
/// Gets or Sets Sweet
/// </summary>
[JsonPropertyName("sweet")]
public bool? Sweet { get { return this.SweetOption; } set { this.SweetOption = new(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class Orange {\n");
sb.Append(" Sweet: ").Append(Sweet).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="Orange" />
/// </summary>
public class OrangeJsonConverter : JsonConverter<Orange>
{
/// <summary>
/// Deserializes json to <see cref="Orange" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
Option<bool?> sweet = default;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string? localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
switch (localVarJsonPropertyName)
{
case "sweet":
sweet = new Option<bool?>(utf8JsonReader.TokenType == JsonTokenType.Null ? (bool?)null : utf8JsonReader.GetBoolean());
break;
default:
break;
}
}
}
if (sweet.IsSet && sweet.Value == null)
throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
return new Orange(sweet);
}
/// <summary>
/// Serializes a <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, orange, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="Orange" />
/// </summary>
/// <param name="writer"></param>
/// <param name="orange"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
}
}
}

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -5,6 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -6,6 +6,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**ShapeType** | **string** | | **ShapeType** | **string** | |
**TriangleType** | **string** | |
**QuadrilateralType** | **string** | | **QuadrilateralType** | **string** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -9,6 +9,7 @@ The value may be a shape or the 'null' value. The 'nullable' attribute was intro
| Name | Type | Description | Notes | | Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------| |------------ | ------------- | ------------- | -------------|
|**shapeType** | **String** | | | |**shapeType** | **String** | | |
|**triangleType** | **String** | | |
|**quadrilateralType** | **String** | | | |**quadrilateralType** | **String** | | |

View File

@@ -8,6 +8,7 @@
| Name | Type | Description | Notes | | Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------| |------------ | ------------- | ------------- | -------------|
|**shapeType** | **String** | | | |**shapeType** | **String** | | |
|**triangleType** | **String** | | |
|**quadrilateralType** | **String** | | | |**quadrilateralType** | **String** | | |

View File

@@ -9,6 +9,7 @@ The value may be a shape or the 'null' value. This is introduced in OAS schema >
| Name | Type | Description | Notes | | Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------| |------------ | ------------- | ------------- | -------------|
|**shapeType** | **String** | | | |**shapeType** | **String** | | |
|**triangleType** | **String** | | |
|**quadrilateralType** | **String** | | | |**quadrilateralType** | **String** | | |

View File

@@ -34,7 +34,7 @@ use WWW::OpenAPIClient::Object::Child;
use WWW::OpenAPIClient::Object::Human; use WWW::OpenAPIClient::Object::Human;
use WWW::OpenAPIClient::Object::Person; use WWW::OpenAPIClient::Object::Person;
use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::Person", "WWW::OpenAPIClient::Object::Human"); use base ("Class::Accessor", "Class::Data::Inheritable");
# #
#A representation of an adult #A representation of an adult
@@ -87,12 +87,6 @@ sub init
my $args_key = $self->attribute_map->{$attribute}; my $args_key = $self->attribute_map->{$attribute};
$self->$attribute( $args{ $args_key } ); $self->$attribute( $args{ $args_key } );
} }
# initialize parent object Person
$self->WWW::OpenAPIClient::Object::Person::init(%args);
# initialize parent object Human
$self->WWW::OpenAPIClient::Object::Human::init(%args);
} }
# return perl hash # return perl hash
@@ -100,12 +94,6 @@ sub to_hash {
my $self = shift; my $self = shift;
my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
# call Person to_hash and then combine hash
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Person::to_hash };
# call Human to_hash and then combine hash
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Human::to_hash };
return $_hash; return $_hash;
} }
@@ -136,12 +124,6 @@ sub TO_JSON {
} }
} }
# combine parent (Person) TO_JSON
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Person::TO_JSON };
# combine parent (Human) TO_JSON
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Human::TO_JSON };
return $_data; return $_data;
} }
@@ -209,12 +191,6 @@ sub from_hash {
} }
} }
# call parent (Person) from_hash
$self->WWW::OpenAPIClient::Object::Person::from_hash($hash);
# call parent (Human) from_hash
$self->WWW::OpenAPIClient::Object::Human::from_hash($hash);
return $self; return $self;
} }

View File

@@ -15,6 +15,7 @@ PetstoreClient/Classes/OpenAPIs/Models.swift
PetstoreClient/Classes/OpenAPIs/Models/Apple.swift PetstoreClient/Classes/OpenAPIs/Models/Apple.swift
PetstoreClient/Classes/OpenAPIs/Models/Banana.swift PetstoreClient/Classes/OpenAPIs/Models/Banana.swift
PetstoreClient/Classes/OpenAPIs/Models/Fruit.swift PetstoreClient/Classes/OpenAPIs/Models/Fruit.swift
PetstoreClient/Classes/OpenAPIs/Models/Orange.swift
PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift
PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift
PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift
@@ -24,5 +25,6 @@ docs/Apple.md
docs/Banana.md docs/Banana.md
docs/DefaultAPI.md docs/DefaultAPI.md
docs/Fruit.md docs/Fruit.md
docs/Orange.md
git_push.sh git_push.sh
project.yml project.yml

View File

@@ -13,6 +13,7 @@ import AnyCodable
public enum Fruit: Codable, JSONEncodable, Hashable { public enum Fruit: Codable, JSONEncodable, Hashable {
case typeApple(Apple) case typeApple(Apple)
case typeBanana(Banana) case typeBanana(Banana)
case typeOrange(Orange)
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer() var container = encoder.singleValueContainer()
@@ -21,6 +22,8 @@ public enum Fruit: Codable, JSONEncodable, Hashable {
try container.encode(value) try container.encode(value)
case .typeBanana(let value): case .typeBanana(let value):
try container.encode(value) try container.encode(value)
case .typeOrange(let value):
try container.encode(value)
} }
} }
@@ -30,6 +33,8 @@ public enum Fruit: Codable, JSONEncodable, Hashable {
self = .typeApple(value) self = .typeApple(value)
} else if let value = try? container.decode(Banana.self) { } else if let value = try? container.decode(Banana.self) {
self = .typeBanana(value) self = .typeBanana(value)
} else if let value = try? container.decode(Orange.self) {
self = .typeOrange(value)
} else { } else {
throw DecodingError.typeMismatch(Self.Type.self, .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of Fruit")) throw DecodingError.typeMismatch(Self.Type.self, .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of Fruit"))
} }

View File

@@ -0,0 +1,32 @@
//
// Orange.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Orange: Codable, JSONEncodable, Hashable {
public var sweet: Bool?
public init(sweet: Bool? = nil) {
self.sweet = sweet
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case sweet
}
// Encodable protocol methods
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(sweet, forKey: .sweet)
}
}

View File

@@ -34,6 +34,7 @@ Class | Method | HTTP request | Description
- [Apple](docs/Apple.md) - [Apple](docs/Apple.md)
- [Banana](docs/Banana.md) - [Banana](docs/Banana.md)
- [Fruit](docs/Fruit.md) - [Fruit](docs/Fruit.md)
- [Orange](docs/Orange.md)
<a id="documentation-for-authorization"></a> <a id="documentation-for-authorization"></a>

View File

@@ -6,6 +6,7 @@ Name | Type | Description | Notes
**color** | **String** | | [optional] **color** | **String** | | [optional]
**kind** | **String** | | [optional] **kind** | **String** | | [optional]
**count** | **Double** | | [optional] **count** | **Double** | | [optional]
**sweet** | **Bool** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,11 @@
# Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**sweet** | **Bool** | | [optional]
**color** | **String** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -19,10 +19,12 @@ PetstoreClient/Classes/OpenAPIs/Infrastructure/Validation.swift
PetstoreClient/Classes/OpenAPIs/Models/Apple.swift PetstoreClient/Classes/OpenAPIs/Models/Apple.swift
PetstoreClient/Classes/OpenAPIs/Models/Banana.swift PetstoreClient/Classes/OpenAPIs/Models/Banana.swift
PetstoreClient/Classes/OpenAPIs/Models/Fruit.swift PetstoreClient/Classes/OpenAPIs/Models/Fruit.swift
PetstoreClient/Classes/OpenAPIs/Models/Orange.swift
README.md README.md
docs/Apple.md docs/Apple.md
docs/Banana.md docs/Banana.md
docs/DefaultAPI.md docs/DefaultAPI.md
docs/Fruit.md docs/Fruit.md
docs/Orange.md
git_push.sh git_push.sh
project.yml project.yml

View File

@@ -10,6 +10,7 @@ import Foundation
public enum Fruit: Sendable, Codable, ParameterConvertible, Hashable { public enum Fruit: Sendable, Codable, ParameterConvertible, Hashable {
case typeApple(Apple) case typeApple(Apple)
case typeBanana(Banana) case typeBanana(Banana)
case typeOrange(Orange)
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer() var container = encoder.singleValueContainer()
@@ -18,6 +19,8 @@ public enum Fruit: Sendable, Codable, ParameterConvertible, Hashable {
try container.encode(value) try container.encode(value)
case .typeBanana(let value): case .typeBanana(let value):
try container.encode(value) try container.encode(value)
case .typeOrange(let value):
try container.encode(value)
} }
} }
@@ -27,6 +30,8 @@ public enum Fruit: Sendable, Codable, ParameterConvertible, Hashable {
self = .typeApple(value) self = .typeApple(value)
} else if let value = try? container.decode(Banana.self) { } else if let value = try? container.decode(Banana.self) {
self = .typeBanana(value) self = .typeBanana(value)
} else if let value = try? container.decode(Orange.self) {
self = .typeOrange(value)
} else { } else {
throw DecodingError.typeMismatch(Self.Type.self, .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of Fruit")) throw DecodingError.typeMismatch(Self.Type.self, .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of Fruit"))
} }

View File

@@ -0,0 +1,29 @@
//
// Orange.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//
import Foundation
public struct Orange: Sendable, Codable, ParameterConvertible, Hashable {
public var sweet: Bool?
public init(sweet: Bool? = nil) {
self.sweet = sweet
}
public enum CodingKeys: String, CodingKey, CaseIterable {
case sweet
}
// Encodable protocol methods
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(sweet, forKey: .sweet)
}
}

View File

@@ -34,6 +34,7 @@ Class | Method | HTTP request | Description
- [Apple](docs/Apple.md) - [Apple](docs/Apple.md)
- [Banana](docs/Banana.md) - [Banana](docs/Banana.md)
- [Fruit](docs/Fruit.md) - [Fruit](docs/Fruit.md)
- [Orange](docs/Orange.md)
<a id="documentation-for-authorization"></a> <a id="documentation-for-authorization"></a>

View File

@@ -6,6 +6,7 @@ Name | Type | Description | Notes
**color** | **String** | | [optional] **color** | **String** | | [optional]
**kind** | **String** | | [optional] **kind** | **String** | | [optional]
**count** | **Double** | | [optional] **count** | **Double** | | [optional]
**sweet** | **Bool** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,11 @@
# Orange
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**sweet** | **Bool** | | [optional]
**color** | **String** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -7,6 +7,7 @@ The value may be a shape or the \'null\' value. The \'nullable\' attribute was i
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**shapeType** | **string** | | [default to undefined] **shapeType** | **string** | | [default to undefined]
**triangleType** | **string** | | [default to undefined]
**quadrilateralType** | **string** | | [default to undefined] **quadrilateralType** | **string** | | [default to undefined]
## Example ## Example
@@ -16,6 +17,7 @@ import { NullableShape } from './api';
const instance: NullableShape = { const instance: NullableShape = {
shapeType, shapeType,
triangleType,
quadrilateralType, quadrilateralType,
}; };
``` ```

View File

@@ -6,6 +6,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**shapeType** | **string** | | [default to undefined] **shapeType** | **string** | | [default to undefined]
**triangleType** | **string** | | [default to undefined]
**quadrilateralType** | **string** | | [default to undefined] **quadrilateralType** | **string** | | [default to undefined]
## Example ## Example
@@ -15,6 +16,7 @@ import { Shape } from './api';
const instance: Shape = { const instance: Shape = {
shapeType, shapeType,
triangleType,
quadrilateralType, quadrilateralType,
}; };
``` ```

View File

@@ -7,6 +7,7 @@ The value may be a shape or the \'null\' value. This is introduced in OAS schema
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**shapeType** | **string** | | [default to undefined] **shapeType** | **string** | | [default to undefined]
**triangleType** | **string** | | [default to undefined]
**quadrilateralType** | **string** | | [default to undefined] **quadrilateralType** | **string** | | [default to undefined]
## Example ## Example
@@ -16,6 +17,7 @@ import { ShapeOrNull } from './api';
const instance: ShapeOrNull = { const instance: ShapeOrNull = {
shapeType, shapeType,
triangleType,
quadrilateralType, quadrilateralType,
}; };
``` ```

View File

@@ -5,6 +5,7 @@ doc/Apple.md
doc/Banana.md doc/Banana.md
doc/DefaultApi.md doc/DefaultApi.md
doc/Fruit.md doc/Fruit.md
doc/Orange.md
lib/openapi.dart lib/openapi.dart
lib/src/api.dart lib/src/api.dart
lib/src/api/default_api.dart lib/src/api/default_api.dart
@@ -19,5 +20,6 @@ lib/src/model/apple.dart
lib/src/model/banana.dart lib/src/model/banana.dart
lib/src/model/date.dart lib/src/model/date.dart
lib/src/model/fruit.dart lib/src/model/fruit.dart
lib/src/model/orange.dart
lib/src/serializers.dart lib/src/serializers.dart
pubspec.yaml pubspec.yaml

View File

@@ -72,6 +72,7 @@ Class | Method | HTTP request | Description
- [Apple](doc/Apple.md) - [Apple](doc/Apple.md)
- [Banana](doc/Banana.md) - [Banana](doc/Banana.md)
- [Fruit](doc/Fruit.md) - [Fruit](doc/Fruit.md)
- [Orange](doc/Orange.md)
## Documentation For Authorization ## Documentation For Authorization

View File

@@ -11,6 +11,7 @@ Name | Type | Description | Notes
**color** | **String** | | [optional] **color** | **String** | | [optional]
**kind** | **String** | | [optional] **kind** | **String** | | [optional]
**count** | **num** | | [optional] **count** | **num** | | [optional]
**sweet** | **bool** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,15 @@
# openapi.model.Orange
## Load the model package
```dart
import 'package:openapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**sweet** | **bool** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -15,4 +15,5 @@ export 'package:openapi/src/api/default_api.dart';
export 'package:openapi/src/model/apple.dart'; export 'package:openapi/src/model/apple.dart';
export 'package:openapi/src/model/banana.dart'; export 'package:openapi/src/model/banana.dart';
export 'package:openapi/src/model/fruit.dart'; export 'package:openapi/src/model/fruit.dart';
export 'package:openapi/src/model/orange.dart';

View File

@@ -5,6 +5,7 @@
// ignore_for_file: unused_element // ignore_for_file: unused_element
import 'package:openapi/src/model/apple.dart'; import 'package:openapi/src/model/apple.dart';
import 'package:openapi/src/model/banana.dart'; import 'package:openapi/src/model/banana.dart';
import 'package:openapi/src/model/orange.dart';
import 'package:built_value/built_value.dart'; import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart'; import 'package:built_value/serializer.dart';
import 'package:one_of/one_of.dart'; import 'package:one_of/one_of.dart';
@@ -17,12 +18,13 @@ part 'fruit.g.dart';
/// * [color] /// * [color]
/// * [kind] /// * [kind]
/// * [count] /// * [count]
/// * [sweet]
@BuiltValue() @BuiltValue()
abstract class Fruit implements Built<Fruit, FruitBuilder> { abstract class Fruit implements Built<Fruit, FruitBuilder> {
@BuiltValueField(wireName: r'color') @BuiltValueField(wireName: r'color')
String? get color; String? get color;
/// One Of [Apple], [Banana] /// One Of [Apple], [Banana], [Orange]
OneOf get oneOf; OneOf get oneOf;
Fruit._(); Fruit._();
@@ -104,7 +106,7 @@ class _$FruitSerializer implements PrimitiveSerializer<Fruit> {
}) { }) {
final result = FruitBuilder(); final result = FruitBuilder();
Object? oneOfDataSrc; Object? oneOfDataSrc;
final targetType = const FullType(OneOf, [FullType(Apple), FullType(Banana), ]); final targetType = const FullType(OneOf, [FullType(Apple), FullType(Banana), FullType(Orange), ]);
final serializedList = (serialized as Iterable<Object?>).toList(); final serializedList = (serialized as Iterable<Object?>).toList();
final unhandled = <Object?>[]; final unhandled = <Object?>[];
_deserializeProperties( _deserializeProperties(

View File

@@ -0,0 +1,108 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// ignore_for_file: unused_element
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'orange.g.dart';
/// Orange
///
/// Properties:
/// * [sweet]
@BuiltValue()
abstract class Orange implements Built<Orange, OrangeBuilder> {
@BuiltValueField(wireName: r'sweet')
bool? get sweet;
Orange._();
factory Orange([void updates(OrangeBuilder b)]) = _$Orange;
@BuiltValueHook(initializeBuilder: true)
static void _defaults(OrangeBuilder b) => b;
@BuiltValueSerializer(custom: true)
static Serializer<Orange> get serializer => _$OrangeSerializer();
}
class _$OrangeSerializer implements PrimitiveSerializer<Orange> {
@override
final Iterable<Type> types = const [Orange, _$Orange];
@override
final String wireName = r'Orange';
Iterable<Object?> _serializeProperties(
Serializers serializers,
Orange object, {
FullType specifiedType = FullType.unspecified,
}) sync* {
if (object.sweet != null) {
yield r'sweet';
yield serializers.serialize(
object.sweet,
specifiedType: const FullType(bool),
);
}
}
@override
Object serialize(
Serializers serializers,
Orange object, {
FullType specifiedType = FullType.unspecified,
}) {
return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
}
void _deserializeProperties(
Serializers serializers,
Object serialized, {
FullType specifiedType = FullType.unspecified,
required List<Object?> serializedList,
required OrangeBuilder result,
required List<Object?> unhandled,
}) {
for (var i = 0; i < serializedList.length; i += 2) {
final key = serializedList[i] as String;
final value = serializedList[i + 1];
switch (key) {
case r'sweet':
final valueDes = serializers.deserialize(
value,
specifiedType: const FullType(bool),
) as bool;
result.sweet = valueDes;
break;
default:
unhandled.add(key);
unhandled.add(value);
break;
}
}
}
@override
Orange deserialize(
Serializers serializers,
Object serialized, {
FullType specifiedType = FullType.unspecified,
}) {
final result = OrangeBuilder();
final serializedList = (serialized as Iterable<Object?>).toList();
final unhandled = <Object?>[];
_deserializeProperties(
serializers,
serialized,
specifiedType: specifiedType,
serializedList: serializedList,
unhandled: unhandled,
result: result,
);
return result.build();
}
}

View File

@@ -17,6 +17,7 @@ import 'package:openapi/src/model/date.dart';
import 'package:openapi/src/model/apple.dart'; import 'package:openapi/src/model/apple.dart';
import 'package:openapi/src/model/banana.dart'; import 'package:openapi/src/model/banana.dart';
import 'package:openapi/src/model/fruit.dart'; import 'package:openapi/src/model/fruit.dart';
import 'package:openapi/src/model/orange.dart';
part 'serializers.g.dart'; part 'serializers.g.dart';
@@ -24,6 +25,7 @@ part 'serializers.g.dart';
Apple, Apple,
Banana, Banana,
Fruit, Fruit,
Orange,
]) ])
Serializers serializers = (_$serializers.toBuilder() Serializers serializers = (_$serializers.toBuilder()
..add(const OneOfSerializer()) ..add(const OneOfSerializer())

View File

@@ -0,0 +1,16 @@
import 'package:test/test.dart';
import 'package:openapi/openapi.dart';
// tests for Orange
void main() {
final instance = OrangeBuilder();
// TODO add properties to the builder and call build()
group(Orange, () {
// bool sweet
test('to test the property `sweet`', () async {
// TODO
});
});
}