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 | StudentResult body = new StudentResult { Email = "student616@oxford.ac.uk", ["Theory Of Automata"] = 82.1, ["Computational complexity"] = 72.5, ["Functional programming"] = 78.3, };
|
false (default) | StudentResult body = new StudentResult { Email = "student616@oxford.ac.uk", };
|
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();
|
Value | Change |
true | $body = StudentResultBuilder::init( 'student616@oxford.ac.uk' ) ->additionalProperty('Theory Of Automata', 82.1) ->additionalProperty('Computational complexity', 72.5) ->additionalProperty('Functional programming', 78.3) ->build();
|
false (default) | $body = StudentResultBuilder::init( 'student616@oxford.ac.uk' )->build();
|
Value | Change |
true | body = StudentResult( email='student616@oxford.ac.uk', additional_properties={ 'Theory Of Automata': 82.1, 'Computational complexity': 72.5, 'Functional programming': 78.3 } )
|
false (default) | body = StudentResult( email='student616@oxford.ac.uk' )
|
Value | Change |
true | body = StudentResult.new( 'student616@oxford.ac.uk', { 'Theory Of Automata': 82.1, 'Computational complexity': 72.5, 'Functional programming': 78.3 } )
|
false (default) | body = StudentResult.new( 'student616@oxford.ac.uk' )
|
Value | Change |
true | const body: StudentResult = { email: 'student616@oxford.ac.uk', additionalProperties: { 'Theory Of Automata': 82.1, 'Computational complexity': 72.5, 'Functional programming': 78.3 }, };
|
false (default) | const body: StudentResult = { email: 'student616@oxford.ac.uk', };
|
Value | Change |
true | body := models.StudentResult{ Email: "student616@oxford.ac.uk", AdditionalProperties: map[string]float64{ "Theory Of Automata": float64(82.1), "Computational complexity": float64(72.5), "Functional programming": float64(78.3), }, }
|
false (default) | body := models.StudentResult{ Email: "student616@oxford.ac.uk", }
|
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 | PersonModel result = await responseTypesController.GetModelAsync();
|
false (default) | Person result = await responseTypesController.GetModelAsync();
|
Value | Change |
true | CompletableFuture<PersonModel> queryEchoAsync( final Map<String, Object> queryParameters)
|
false (default) | CompletableFuture<Person> queryEchoAsync( final Map<String, Object> queryParameters)
|
Value | Change |
true | function sendDeleteBody(DeleteBodyModel $body): ServerResponseModel
|
false (default) | function sendDeleteBody(DeleteBody $body): ServerResponse
|
Value | Change |
true | from tester.models.person import PersonModel
|
false (default) | from tester.models.person import Person
|
Value | Change |
true | body = DeleteBodyModel.from_hash(APIHelper.json_deserialize( '{"name":" ","field":"QA"}', false))
|
false (default) | body = DeleteBody.from_hash(APIHelper.json_deserialize( '{"name":" ","field":"QA"}', false))
|
Value | Change |
true | async queryEcho( queryParameters?: Record<string, string>, requestOptions?: RequestOptions ): Promise<ApiResponse<PersonModel>>
|
false (default) | async queryEcho( queryParameters?: Record<string, string>, requestOptions?: RequestOptions ): Promise<ApiResponse<Person>>
|
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")
|