Skip to main content

Model

These CodeGen configurations manage the model-specific behavior in the generated SDKs.

Extended Additional Properties Support

In cases where your OpenAPI specification includes typed additional properties for models, enabling the Extended Additional Properties Support setting ensures that these properties are correctly handled in the generated SDKs. When this option is enabled, models will support typed additional properties, allowing you to define specific data types for additional fields instead of using a generic type.

This feature ensures better alignment with OpenAPI specifications by enabling type safety for additional properties. It also improves consistency, reduces the risk of runtime errors, and provides more flexibility when working with models that include additional, user-defined properties.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to false.

"info": {
...,
"x-codegen-settings": {
"ExtendedAdditionalPropertiesSupport": true
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Change in SDK

Configuring this setting has the following effect on the generated SDK:

Value Change
true
StudentResult body = new StudentResult.Builder(
"student616@oxford.ac.uk"
)
.additionalProperty("Theory Of Automata", 82.1D)
.additionalProperty("Computational complexity", 72.5D)
.additionalProperty("Functional programming", 78.3D)
.build();
false (default)
StudentResult body = new StudentResult.Builder(
"student616@oxford.ac.uk"
)
.build();

Use Model Prefix

Enabling this setting will postfix each model class with the word "Model."

This setting is helpful in cases where in an OpenAPI specification, an API, endpoint, model, controller etc. might have the same name which can lead to confusion. So, to distinguish between them, you can use this setting to specify that it's a model. For example, a model Person becomes PersonModel.

note

Try to use this setting only if there's a chance of naming conflicts in your API specification file.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to false.

"info": {
...,
"x-codegen-settings": {
"UseModelPrefix": false
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️

Change in SDK

Configuring this setting has the following effect on the generated SDK:

Value Change
true
CompletableFuture<PersonModel> queryEchoAsync(
final Map<String, Object> queryParameters)
false (default)
CompletableFuture<Person> queryEchoAsync(
final Map<String, Object> queryParameters)

Enable Model Keyword Args in Ruby

This setting determines the usage of keyword arguments for properties in the constructor of models in Ruby SDKs. If enabled, then all parameters are expected to be provided in the argument name along with value during the model instantiation. If disabled, the model constructor expects positional arguments.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to false.

"info": {
...,
"x-codegen-settings": {
"EnableModelKeywordArgsInRuby": true
}
}

Language Support

This setting only applies to Ruby SDKs.

Change in SDK

Configuring this setting has the following effect on the generated SDK:

Value Change
true
class User
def initialize(name:, email:)
@name = name
@email = email
end
end

user = User.new(email: "bob@example.com", name: "Bob")
false (default)
class User
def initialize(name, email)
@name = name
@email = email
end
end

user = User.new("Alice", "alice@example.com")

Skip Equality Methods in CSharp

This setting controls whether the .NET SDK generator creates Equals and GetHashCode implementations for models and related container types.

When enabled, the generator doesn't produce Equals and GetHashCode methods for:

  • Models
  • OneOf / AnyOf cases
  • Webhooks and Callbacks ParsingResult

Impact

  • Prevents incorrect equality and hashing behavior on mutable models, which can otherwise result in invalid comparisons or objects becoming unreachable in hash-based collections such as Dictionary and HashSet.
  • Equality checks fall back to reference comparison unless explicitly implemented by the developer.
  • Any code relying on value-based equality (Equals, ==, Dictionary, HashSet) may observe different behavior.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to false.

"info": {
...,
"x-codegen-settings": {
"CSharpSkipEqualityMethods": true
}
}

Language Support

This setting only applies to .NET SDKs.

Change in SDK

Configuring this setting has the following effect on the generated SDK:

Value Change
true
public class User
{
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// </summary>
public User()
{
}

...

// Skips public override bool Equals(object obj) { ... }
...
}
false (default)
public class User
{
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// </summary>
public User()
{
...
}

...

// <inheritdoc/>
public override bool Equals(object obj)
{
...
}
...
}