Skip to content

Commit 59a73a7

Browse files
committed
Merge branch 'ircecho-patch-1'
2 parents a07d602 + 7c8333e commit 59a73a7

File tree

9 files changed

+376
-33
lines changed

9 files changed

+376
-33
lines changed

modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@
124124
return false if @{{{name}}}.nil?
125125
{{/required}}
126126
{{#isEnum}}
127+
{{^isContainer}}
127128
{{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
128129
return false unless {{{name}}}_validator.valid?(@{{{name}}})
130+
{{/isContainer}}
129131
{{/isEnum}}
130132
{{#hasValidation}}
131133
{{#minLength}}
@@ -150,6 +152,7 @@
150152

151153
{{#vars}}
152154
{{#isEnum}}
155+
{{^isContainer}}
153156
# Custom attribute writer method checking allowed values (enum).
154157
# @param [Object] {{{name}}} Object to be assigned
155158
def {{{name}}}=({{{name}}})
@@ -160,6 +163,7 @@
160163
@{{{name}}} = {{{name}}}
161164
end
162165

166+
{{/isContainer}}
163167
{{/isEnum}}
164168
{{^isEnum}}
165169
{{#hasValidation}}

samples/client/petstore/ruby/README.md

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
88

99
- API version: 1.0.0
1010
- Package version: 1.0.0
11-
- Build date: 2016-07-04T22:10:18.328+08:00
11+
- Build date: 2016-07-14T16:12:28.313+08:00
1212
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
1313

1414
## Installation
@@ -57,30 +57,15 @@ require 'petstore'
5757

5858
api_instance = Petstore::FakeApi.new
5959

60-
number = 3.4 # Float | None
60+
body = Petstore::Client.new # Client | client model
6161

62-
double = 1.2 # Float | None
63-
64-
string = "string_example" # String | None
65-
66-
byte = "B" # String | None
67-
68-
opts = {
69-
integer: 56, # Integer | None
70-
int32: 56, # Integer | None
71-
int64: 789, # Integer | None
72-
float: 3.4, # Float | None
73-
binary: "B", # String | None
74-
date: Date.parse("2013-10-20"), # Date | None
75-
date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None
76-
password: "password_example" # String | None
77-
}
7862

7963
begin
80-
#Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
81-
api_instance.test_endpoint_parameters(number, double, string, byte, opts)
64+
#To test \"client\" model
65+
result = api_instance.test_client_model(body)
66+
p result
8267
rescue Petstore::ApiError => e
83-
puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}"
68+
puts "Exception when calling FakeApi->test_client_model: #{e}"
8469
end
8570

8671
```
@@ -91,6 +76,7 @@ All URIs are relative to *http://petstore.swagger.io/v2*
9176

9277
Class | Method | HTTP request | Description
9378
------------ | ------------- | ------------- | -------------
79+
*Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
9480
*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
9581
*Petstore::FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
9682
*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
@@ -126,6 +112,7 @@ Class | Method | HTTP request | Description
126112
- [Petstore::ArrayTest](docs/ArrayTest.md)
127113
- [Petstore::Cat](docs/Cat.md)
128114
- [Petstore::Category](docs/Category.md)
115+
- [Petstore::Client](docs/Client.md)
129116
- [Petstore::Dog](docs/Dog.md)
130117
- [Petstore::EnumClass](docs/EnumClass.md)
131118
- [Petstore::EnumTest](docs/EnumTest.md)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Petstore::Client
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**client** | **String** | | [optional]
7+
8+

samples/client/petstore/ruby/docs/FakeApi.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,56 @@ All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7+
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
78
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
89
[**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
910

1011

12+
# **test_client_model**
13+
> Client test_client_model(body)
14+
15+
To test \"client\" model
16+
17+
### Example
18+
```ruby
19+
# load the gem
20+
require 'petstore'
21+
22+
api_instance = Petstore::FakeApi.new
23+
24+
body = Petstore::Client.new # Client | client model
25+
26+
27+
begin
28+
#To test \"client\" model
29+
result = api_instance.test_client_model(body)
30+
p result
31+
rescue Petstore::ApiError => e
32+
puts "Exception when calling FakeApi->test_client_model: #{e}"
33+
end
34+
```
35+
36+
### Parameters
37+
38+
Name | Type | Description | Notes
39+
------------- | ------------- | ------------- | -------------
40+
**body** | [**Client**](Client.md)| client model |
41+
42+
### Return type
43+
44+
[**Client**](Client.md)
45+
46+
### Authorization
47+
48+
No authorization required
49+
50+
### HTTP request headers
51+
52+
- **Content-Type**: application/json
53+
- **Accept**: application/json
54+
55+
56+
1157
# **test_endpoint_parameters**
1258
> test_endpoint_parameters(number, double, string, byte, opts)
1359

samples/client/petstore/ruby/lib/petstore.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
require 'petstore/models/array_test'
3838
require 'petstore/models/cat'
3939
require 'petstore/models/category'
40+
require 'petstore/models/client'
4041
require 'petstore/models/dog'
4142
require 'petstore/models/enum_class'
4243
require 'petstore/models/enum_test'

samples/client/petstore/ruby/lib/petstore/api/fake_api.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,63 @@ def initialize(api_client = ApiClient.default)
3131
@api_client = api_client
3232
end
3333

34+
# To test \"client\" model
35+
#
36+
# @param body client model
37+
# @param [Hash] opts the optional parameters
38+
# @return [Client]
39+
def test_client_model(body, opts = {})
40+
data, _status_code, _headers = test_client_model_with_http_info(body, opts)
41+
return data
42+
end
43+
44+
# To test \"client\" model
45+
#
46+
# @param body client model
47+
# @param [Hash] opts the optional parameters
48+
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
49+
def test_client_model_with_http_info(body, opts = {})
50+
if @api_client.config.debugging
51+
@api_client.config.logger.debug "Calling API: FakeApi.test_client_model ..."
52+
end
53+
# verify the required parameter 'body' is set
54+
fail ArgumentError, "Missing the required parameter 'body' when calling FakeApi.test_client_model" if body.nil?
55+
# resource path
56+
local_var_path = "/fake".sub('{format}','json')
57+
58+
# query parameters
59+
query_params = {}
60+
61+
# header parameters
62+
header_params = {}
63+
64+
# HTTP header 'Accept' (if needed)
65+
local_header_accept = ['application/json']
66+
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
67+
68+
# HTTP header 'Content-Type'
69+
local_header_content_type = ['application/json']
70+
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
71+
72+
# form parameters
73+
form_params = {}
74+
75+
# http body (model)
76+
post_body = @api_client.object_to_http_body(body)
77+
auth_names = []
78+
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
79+
:header_params => header_params,
80+
:query_params => query_params,
81+
:form_params => form_params,
82+
:body => post_body,
83+
:auth_names => auth_names,
84+
:return_type => 'Client')
85+
if @api_client.config.debugging
86+
@api_client.config.logger.debug "API called: FakeApi#test_client_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
87+
end
88+
return data, status_code, headers
89+
end
90+
3491
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
3592
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
3693
# @param number None

0 commit comments

Comments
 (0)