Skip to content

Commit f1f0104

Browse files
committed
update ruby sample
1 parent 9e216c0 commit f1f0104

38 files changed

+158
-71
lines changed

samples/client/petstore/ruby/README.md

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Petstore - the Ruby gem for the Swagger Petstore
44

5-
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
5+
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
66

77
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
88

99
- API version: 1.0.0
1010
- Package version: 1.0.0
11-
- Build date: 2016-06-28T15:19:55.521+10:00
11+
- Build date: 2016-06-28T17:36:56.204+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
61-
62-
double = 1.2 # Float | None
63-
64-
string = "string_example" # String | None
65-
66-
byte = "B" # String | None
67-
6860
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
61+
test_code_inject__end: "test_code_inject__end_example" # String | To test code injection */
7762
}
7863

7964
begin
80-
#Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
81-
api_instance.test_endpoint_parameters(number, double, string, byte, opts)
65+
#To test code injection */
66+
api_instance.test_code_inject__end(opts)
8267
rescue Petstore::ApiError => e
83-
puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}"
68+
puts "Exception when calling FakeApi->test_code_inject__end: #{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_code_inject__end**](docs/FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */
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
@@ -148,6 +134,12 @@ Class | Method | HTTP request | Description
148134
## Documentation for Authorization
149135

150136

137+
### api_key
138+
139+
- **Type**: API key
140+
- **API key parameter name**: api_key
141+
- **Location**: HTTP header
142+
151143
### petstore_auth
152144

153145
- **Type**: OAuth
@@ -157,9 +149,3 @@ Class | Method | HTTP request | Description
157149
- write:pets: modify pets in your account
158150
- read:pets: read your pets
159151

160-
### api_key
161-
162-
- **Type**: API key
163-
- **API key parameter name**: api_key
164-
- **Location**: HTTP header
165-

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_code_inject__end**](FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */
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_code_inject__end**
13+
> test_code_inject__end(opts)
14+
15+
To test code injection */
16+
17+
### Example
18+
```ruby
19+
# load the gem
20+
require 'petstore'
21+
22+
api_instance = Petstore::FakeApi.new
23+
24+
opts = {
25+
test_code_inject__end: "test_code_inject__end_example" # String | To test code injection */
26+
}
27+
28+
begin
29+
#To test code injection */
30+
api_instance.test_code_inject__end(opts)
31+
rescue Petstore::ApiError => e
32+
puts "Exception when calling FakeApi->test_code_inject__end: #{e}"
33+
end
34+
```
35+
36+
### Parameters
37+
38+
Name | Type | Description | Notes
39+
------------- | ------------- | ------------- | -------------
40+
**test_code_inject__end** | **String**| To test code injection */ | [optional]
41+
42+
### Return type
43+
44+
nil (empty response body)
45+
46+
### Authorization
47+
48+
No authorization required
49+
50+
### HTTP request headers
51+
52+
- **Content-Type**: application/json, */ =end));(phpinfo(
53+
- **Accept**: application/json, */ end
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77
@@ -31,6 +31,61 @@ def initialize(api_client = ApiClient.default)
3131
@api_client = api_client
3232
end
3333

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=begin
22
#Swagger Petstore
33
4-
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
55
66
OpenAPI spec version: 1.0.0
77
@@ -188,20 +188,20 @@ def basic_auth_token
188188
# Returns Auth Settings hash for api client.
189189
def auth_settings
190190
{
191-
'petstore_auth' =>
192-
{
193-
type: 'oauth2',
194-
in: 'header',
195-
key: 'Authorization',
196-
value: "Bearer #{access_token}"
197-
},
198191
'api_key' =>
199192
{
200193
type: 'api_key',
201194
in: 'header',
202195
key: 'api_key',
203196
value: api_key_with_prefix('api_key')
204197
},
198+
'petstore_auth' =>
199+
{
200+
type: 'oauth2',
201+
in: 'header',
202+
key: 'Authorization',
203+
value: "Bearer #{access_token}"
204+
},
205205
}
206206
end
207207
end

0 commit comments

Comments
 (0)