Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/configs/ruby.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ additionalProperties:
gemName: petstore
skipFormModel: "true"
strictSpecBehavior: false
nameMappings:
_type: underscore_type
type_: type_with_underscore
parameterNameMappings:
_type: underscore_type
type_: type_with_underscore
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toVarName(final String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}

String varName = sanitizeName(name);
// if it's all upper case, convert to lower case
if (name.matches("^[A-Z_]*$")) {
Expand All @@ -201,6 +206,11 @@ public String toRegularExpression(String pattern) {

@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}

// should be the same as variable name
return toVarName(name);
}
Expand Down Expand Up @@ -265,5 +275,7 @@ public void postProcessFile(File file, String fileType) {
}

@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.RUBY; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.RUBY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,41 @@ paths:
responses:
200:
description: The instance started successfully
/fake/parameter-name-mapping:
get:
tags:
- fake
summary: parameter name mapping test
operationId: getParameterNameMapping
parameters:
- name: _type
in: header
description: _type
required: true
schema:
type: integer
format: int64
- name: type
in: query
description: type
required: true
schema:
type: string
- name: type_
in: header
description: type_
required: true
schema:
type: string
- name: http_debug_option
in: query
description: http debug option (to test parameter naming option)
required: true
schema:
type: string
responses:
200:
description: OK
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
Expand Down Expand Up @@ -2045,3 +2080,13 @@ components:
required:
- classname
additionalProperties: true
PropertyNameMapping:
properties:
http_debug_operation:
type: string
_type:
type: string
type:
type: string
type_:
type: string
2 changes: 2 additions & 0 deletions samples/client/petstore/ruby/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ docs/OuterEnumIntegerDefaultValue.md
docs/OuterObjectWithEnumProperty.md
docs/Pet.md
docs/PetApi.md
docs/PropertyNameMapping.md
docs/ReadOnlyFirst.md
docs/SingleRefType.md
docs/SpecialModelName.md
Expand Down Expand Up @@ -122,6 +123,7 @@ lib/petstore/models/outer_enum_integer.rb
lib/petstore/models/outer_enum_integer_default_value.rb
lib/petstore/models/outer_object_with_enum_property.rb
lib/petstore/models/pet.rb
lib/petstore/models/property_name_mapping.rb
lib/petstore/models/read_only_first.rb
lib/petstore/models/single_ref_type.rb
lib/petstore/models/special_model_name.rb
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Class | Method | HTTP request | Description
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
*Petstore::FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
*Petstore::FakeApi* | [**fake_property_enum_integer_serialize**](docs/FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int |
*Petstore::FakeApi* | [**get_parameter_name_mapping**](docs/FakeApi.md#get_parameter_name_mapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
*Petstore::FakeApi* | [**test_body_with_binary**](docs/FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary |
*Petstore::FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema |
*Petstore::FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
Expand Down Expand Up @@ -166,6 +167,7 @@ Class | Method | HTTP request | Description
- [Petstore::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [Petstore::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
- [Petstore::Pet](docs/Pet.md)
- [Petstore::PropertyNameMapping](docs/PropertyNameMapping.md)
- [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [Petstore::SingleRefType](docs/SingleRefType.md)
- [Petstore::SpecialModelName](docs/SpecialModelName.md)
Expand Down
68 changes: 68 additions & 0 deletions samples/client/petstore/ruby/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | |
| [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | |
| [**fake_property_enum_integer_serialize**](FakeApi.md#fake_property_enum_integer_serialize) | **POST** /fake/property/enum-int | |
| [**get_parameter_name_mapping**](FakeApi.md#get_parameter_name_mapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test |
| [**test_body_with_binary**](FakeApi.md#test_body_with_binary) | **PUT** /fake/body-with-binary | |
| [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | |
| [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | |
Expand Down Expand Up @@ -542,6 +543,73 @@ No authorization required
- **Accept**: */*


## get_parameter_name_mapping

> get_parameter_name_mapping(underscore_type, type, type_with_underscore, http_debug_option)

parameter name mapping test

### Examples

```ruby
require 'time'
require 'petstore'

api_instance = Petstore::FakeApi.new
underscore_type = 789 # Integer | _type
type = 'type_example' # String | type
type_with_underscore = 'type_with_underscore_example' # String | type_
http_debug_option = 'http_debug_option_example' # String | http debug option (to test parameter naming option)

begin
# parameter name mapping test
api_instance.get_parameter_name_mapping(underscore_type, type, type_with_underscore, http_debug_option)
rescue Petstore::ApiError => e
puts "Error when calling FakeApi->get_parameter_name_mapping: #{e}"
end
```

#### Using the get_parameter_name_mapping_with_http_info variant

This returns an Array which contains the response data (`nil` in this case), status code and headers.

> <Array(nil, Integer, Hash)> get_parameter_name_mapping_with_http_info(underscore_type, type, type_with_underscore, http_debug_option)

```ruby
begin
# parameter name mapping test
data, status_code, headers = api_instance.get_parameter_name_mapping_with_http_info(underscore_type, type, type_with_underscore, http_debug_option)
p status_code # => 2xx
p headers # => { ... }
p data # => nil
rescue Petstore::ApiError => e
puts "Error when calling FakeApi->get_parameter_name_mapping_with_http_info: #{e}"
end
```

### Parameters

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **underscore_type** | **Integer** | _type | |
| **type** | **String** | type | |
| **type_with_underscore** | **String** | type_ | |
| **http_debug_option** | **String** | http debug option (to test parameter naming option) | |

### Return type

nil (empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined


## test_body_with_binary

> test_body_with_binary(body)
Expand Down
24 changes: 24 additions & 0 deletions samples/client/petstore/ruby/docs/PropertyNameMapping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Petstore::PropertyNameMapping

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **http_debug_operation** | **String** | | [optional] |
| **underscore_type** | **String** | | [optional] |
| **type** | **String** | | [optional] |
| **type_with_underscore** | **String** | | [optional] |

## Example

```ruby
require 'petstore'

instance = Petstore::PropertyNameMapping.new(
http_debug_operation: null,
underscore_type: null,
type: null,
type_with_underscore: null
)
```

1 change: 1 addition & 0 deletions samples/client/petstore/ruby/lib/petstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
require 'petstore/models/outer_enum_integer_default_value'
require 'petstore/models/outer_object_with_enum_property'
require 'petstore/models/pet'
require 'petstore/models/property_name_mapping'
require 'petstore/models/read_only_first'
require 'petstore/models/single_ref_type'
require 'petstore/models/special_model_name'
Expand Down
81 changes: 81 additions & 0 deletions samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,87 @@ def fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_p
return data, status_code, headers
end

# parameter name mapping test
# @param underscore_type [Integer] _type
# @param type [String] type
# @param type_with_underscore [String] type_
# @param http_debug_option [String] http debug option (to test parameter naming option)
# @param [Hash] opts the optional parameters
# @return [nil]
def get_parameter_name_mapping(underscore_type, type, type_with_underscore, http_debug_option, opts = {})
get_parameter_name_mapping_with_http_info(underscore_type, type, type_with_underscore, http_debug_option, opts)
nil
end

# parameter name mapping test
# @param underscore_type [Integer] _type
# @param type [String] type
# @param type_with_underscore [String] type_
# @param http_debug_option [String] http debug option (to test parameter naming option)
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def get_parameter_name_mapping_with_http_info(underscore_type, type, type_with_underscore, http_debug_option, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.get_parameter_name_mapping ...'
end
# verify the required parameter 'underscore_type' is set
if @api_client.config.client_side_validation && underscore_type.nil?
fail ArgumentError, "Missing the required parameter 'underscore_type' when calling FakeApi.get_parameter_name_mapping"
end
# verify the required parameter 'type' is set
if @api_client.config.client_side_validation && type.nil?
fail ArgumentError, "Missing the required parameter 'type' when calling FakeApi.get_parameter_name_mapping"
end
# verify the required parameter 'type_with_underscore' is set
if @api_client.config.client_side_validation && type_with_underscore.nil?
fail ArgumentError, "Missing the required parameter 'type_with_underscore' when calling FakeApi.get_parameter_name_mapping"
end
# verify the required parameter 'http_debug_option' is set
if @api_client.config.client_side_validation && http_debug_option.nil?
fail ArgumentError, "Missing the required parameter 'http_debug_option' when calling FakeApi.get_parameter_name_mapping"
end
# resource path
local_var_path = '/fake/parameter-name-mapping'

# query parameters
query_params = opts[:query_params] || {}
query_params[:'type'] = type
query_params[:'http_debug_option'] = http_debug_option

# header parameters
header_params = opts[:header_params] || {}
header_params[:'_type'] = underscore_type
header_params[:'type_'] = type_with_underscore

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body]

# return_type
return_type = opts[:debug_return_type]

# auth_names
auth_names = opts[:debug_auth_names] || []

new_options = opts.merge(
:operation => :"FakeApi.get_parameter_name_mapping",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FakeApi#get_parameter_name_mapping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# For this test, the body has to be a binary file.
# @param body [File] image to upload
# @param [Hash] opts the optional parameters
Expand Down
Loading