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")