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# | Java | PHP | Python | Ruby | TS | Go |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Change in SDK
Configuring this setting has the following effect on the generated SDK:
- C#
- Java
- PHP
- Python
- Ruby
- TypeScript
- Go
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
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.
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# | Java | PHP | Python | Ruby | TS | Go |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ |
Change in SDK
Configuring this setting has the following effect on the generated SDK:
- C#
- Java
- PHP
- Python
- Ruby
- TypeScript
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
| Value | Change |
true | |
false (default) | |
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 | |
false (default) | |
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
DictionaryandHashSet. - 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 | |
false (default) | |