forked from loafle/openapi-generator-original
[Ruby] Better handling of operationID starting with a number (#719)
* better handling of operationId starting with numbers in Ruby * update Rubocop to use Layout
This commit is contained in:
parent
e0020b41da
commit
f0425d77ef
@ -462,6 +462,12 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
return newOperationId;
|
return newOperationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// operationId starts with a number
|
||||||
|
if (operationId.matches("^\\d.*")) {
|
||||||
|
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||||
|
operationId = "call_" + operationId;
|
||||||
|
}
|
||||||
|
|
||||||
return underscore(sanitizeName(operationId));
|
return underscore(sanitizeName(operationId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ Style/UnneededPercentQ:
|
|||||||
|
|
||||||
# Align `end` with the matching keyword or starting expression except for
|
# Align `end` with the matching keyword or starting expression except for
|
||||||
# assignments, where it should be aligned with the LHS.
|
# assignments, where it should be aligned with the LHS.
|
||||||
Lint/EndAlignment:
|
Layout/EndAlignment:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
EnforcedStyleAlignWith: variable
|
EnforcedStyleAlignWith: variable
|
||||||
AutoCorrect: true
|
AutoCorrect: true
|
||||||
|
@ -136,7 +136,7 @@ Style/UnneededPercentQ:
|
|||||||
|
|
||||||
# Align `end` with the matching keyword or starting expression except for
|
# Align `end` with the matching keyword or starting expression except for
|
||||||
# assignments, where it should be aligned with the LHS.
|
# assignments, where it should be aligned with the LHS.
|
||||||
Lint/EndAlignment:
|
Layout/EndAlignment:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
EnforcedStyleAlignWith: variable
|
EnforcedStyleAlignWith: variable
|
||||||
AutoCorrect: true
|
AutoCorrect: true
|
||||||
|
@ -59,10 +59,10 @@ client = Petstore::Client.new # Client | client model
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
#To test special tags
|
#To test special tags
|
||||||
result = api_instance.test_special_tags(client)
|
result = api_instance.call_123_test_special_tags(client)
|
||||||
p result
|
p result
|
||||||
rescue Petstore::ApiError => e
|
rescue Petstore::ApiError => e
|
||||||
puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
|
puts "Exception when calling AnotherFakeApi->call_123_test_special_tags: #{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -73,7 +73,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
*Petstore::AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
*Petstore::AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
||||||
*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
|
*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
|
||||||
*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
|
*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
|
||||||
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
|
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
|
||||||
|
@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
||||||
|
|
||||||
|
|
||||||
# **test_special_tags**
|
# **call_123_test_special_tags**
|
||||||
> Client test_special_tags(client)
|
> Client call_123_test_special_tags(client)
|
||||||
|
|
||||||
To test special tags
|
To test special tags
|
||||||
|
|
||||||
To test special tags
|
To test special tags and operation ID starting with number
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
@ -24,10 +24,10 @@ client = Petstore::Client.new # Client | client model
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
#To test special tags
|
#To test special tags
|
||||||
result = api_instance.test_special_tags(client)
|
result = api_instance.call_123_test_special_tags(client)
|
||||||
p result
|
p result
|
||||||
rescue Petstore::ApiError => e
|
rescue Petstore::ApiError => e
|
||||||
puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
|
puts "Exception when calling AnotherFakeApi->call_123_test_special_tags: #{e}"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -20,27 +20,27 @@ module Petstore
|
|||||||
@api_client = api_client
|
@api_client = api_client
|
||||||
end
|
end
|
||||||
# To test special tags
|
# To test special tags
|
||||||
# To test special tags
|
# To test special tags and operation ID starting with number
|
||||||
# @param client client model
|
# @param client client model
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return [Client]
|
# @return [Client]
|
||||||
def test_special_tags(client, opts = {})
|
def call_123_test_special_tags(client, opts = {})
|
||||||
data, _status_code, _headers = test_special_tags_with_http_info(client, opts)
|
data, _status_code, _headers = call_123_test_special_tags_with_http_info(client, opts)
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
# To test special tags
|
# To test special tags
|
||||||
# To test special tags
|
# To test special tags and operation ID starting with number
|
||||||
# @param client client model
|
# @param client client model
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
|
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
|
||||||
def test_special_tags_with_http_info(client, opts = {})
|
def call_123_test_special_tags_with_http_info(client, opts = {})
|
||||||
if @api_client.config.debugging
|
if @api_client.config.debugging
|
||||||
@api_client.config.logger.debug 'Calling API: AnotherFakeApi.test_special_tags ...'
|
@api_client.config.logger.debug 'Calling API: AnotherFakeApi.call_123_test_special_tags ...'
|
||||||
end
|
end
|
||||||
# verify the required parameter 'client' is set
|
# verify the required parameter 'client' is set
|
||||||
if @api_client.config.client_side_validation && client.nil?
|
if @api_client.config.client_side_validation && client.nil?
|
||||||
fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.test_special_tags"
|
fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.call_123_test_special_tags"
|
||||||
end
|
end
|
||||||
# resource path
|
# resource path
|
||||||
local_var_path = '/another-fake/dummy'
|
local_var_path = '/another-fake/dummy'
|
||||||
@ -69,7 +69,7 @@ module Petstore
|
|||||||
:auth_names => auth_names,
|
:auth_names => auth_names,
|
||||||
:return_type => 'Client')
|
:return_type => 'Client')
|
||||||
if @api_client.config.debugging
|
if @api_client.config.debugging
|
||||||
@api_client.config.logger.debug "API called: AnotherFakeApi#test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
@api_client.config.logger.debug "API called: AnotherFakeApi#call_123_test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||||
end
|
end
|
||||||
return data, status_code, headers
|
return data, status_code, headers
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user