forked from loafle/openapi-generator-original
update user-agent for Ruby
This commit is contained in:
parent
df8d4fd8b8
commit
e10c28596c
@ -115,7 +115,7 @@ public class Generate implements Runnable {
|
|||||||
@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE_DESC)
|
@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE_DESC)
|
||||||
private String releaseNote;
|
private String releaseNote;
|
||||||
|
|
||||||
@Option(name = {"--http-user-agent"}, title = "http user agent", description = CodegenConstants.HTTP_USER_AGENT)
|
@Option(name = {"--http-user-agent"}, title = "http user agent", description = CodegenConstants.HTTP_USER_AGENT_DESC)
|
||||||
private String httpUserAgent;
|
private String httpUserAgent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,6 +101,6 @@ public class CodegenConstants {
|
|||||||
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";
|
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";
|
||||||
|
|
||||||
public static final String HTTP_USER_AGENT = "httpUserAgent";
|
public static final String HTTP_USER_AGENT = "httpUserAgent";
|
||||||
public static final String HTTP_USER_AGENT_DESC = "HTTP user agent, e.g. codegen_csharp_api_client, default to 'Swagger-Codegen/{releaseVersion}}/{language}'";
|
public static final String HTTP_USER_AGENT_DESC = "HTTP user agent, e.g. codegen_csharp_api_client, default to 'Swagger-Codegen/{packageVersion}}/{language}'";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ module {{moduleName}}
|
|||||||
|
|
||||||
def initialize(config = Configuration.default)
|
def initialize(config = Configuration.default)
|
||||||
@config = config
|
@config = config
|
||||||
@user_agent = "ruby-swagger-#{VERSION}"
|
@user_agent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}"
|
||||||
@default_headers = {
|
@default_headers = {
|
||||||
'Content-Type' => "application/json",
|
'Content-Type' => "application/json",
|
||||||
'User-Agent' => @user_agent
|
'User-Agent' => @user_agent
|
||||||
|
@ -6,7 +6,7 @@ Version: 1.0.0
|
|||||||
|
|
||||||
Automatically generated by the Ruby Swagger Codegen project:
|
Automatically generated by the Ruby Swagger Codegen project:
|
||||||
|
|
||||||
- Build date: 2016-03-14T15:33:44.953+08:00
|
- Build date: 2016-03-14T21:56:19.858+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -119,25 +119,10 @@ Class | Method | HTTP request | Description
|
|||||||
## Documentation for Authorization
|
## Documentation for Authorization
|
||||||
|
|
||||||
|
|
||||||
### petstore_auth
|
### test_api_key_header
|
||||||
|
|
||||||
- **Type**: OAuth
|
|
||||||
- **Flow**: implicit
|
|
||||||
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
- **Scopes**:
|
|
||||||
-- write:pets: modify pets in your account
|
|
||||||
-- read:pets: read your pets
|
|
||||||
|
|
||||||
### test_api_client_id
|
|
||||||
|
|
||||||
- **Type**: API key
|
- **Type**: API key
|
||||||
- **API key parameter name**: x-test_api_client_id
|
- **API key parameter name**: test_api_key_header
|
||||||
- **Location**: HTTP header
|
|
||||||
|
|
||||||
### test_api_client_secret
|
|
||||||
|
|
||||||
- **Type**: API key
|
|
||||||
- **API key parameter name**: x-test_api_client_secret
|
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
### api_key
|
### api_key
|
||||||
@ -150,15 +135,30 @@ Class | Method | HTTP request | Description
|
|||||||
|
|
||||||
- **Type**: HTTP basic authentication
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
### test_api_client_secret
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: x-test_api_client_secret
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
### test_api_client_id
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: x-test_api_client_id
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
### test_api_key_query
|
### test_api_key_query
|
||||||
|
|
||||||
- **Type**: API key
|
- **Type**: API key
|
||||||
- **API key parameter name**: test_api_key_query
|
- **API key parameter name**: test_api_key_query
|
||||||
- **Location**: URL query string
|
- **Location**: URL query string
|
||||||
|
|
||||||
### test_api_key_header
|
### petstore_auth
|
||||||
|
|
||||||
- **Type**: API key
|
- **Type**: OAuth
|
||||||
- **API key parameter name**: test_api_key_header
|
- **Flow**: implicit
|
||||||
- **Location**: HTTP header
|
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
-- write:pets: modify pets in your account
|
||||||
|
-- read:pets: read your pets
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**photo_urls** | **Array<String>** | | [optional]
|
**tags** | [**Array<Tag>**](Tag.md) | | [optional]
|
||||||
**name** | **String** | | [optional]
|
|
||||||
**id** | **Integer** | |
|
**id** | **Integer** | |
|
||||||
**category** | **Object** | | [optional]
|
**category** | **Object** | | [optional]
|
||||||
**tags** | [**Array<Tag>**](Tag.md) | | [optional]
|
|
||||||
**status** | **String** | pet status in the store | [optional]
|
**status** | **String** | pet status in the store | [optional]
|
||||||
|
**name** | **String** | | [optional]
|
||||||
|
**photo_urls** | **Array<String>** | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,13 +284,13 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
|||||||
require 'petstore'
|
require 'petstore'
|
||||||
|
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
|
||||||
config.access_token = "YOUR ACCESS TOKEN"
|
|
||||||
|
|
||||||
# Configure API key authorization: api_key
|
# Configure API key authorization: api_key
|
||||||
config.api_key['api_key'] = "YOUR API KEY"
|
config.api_key['api_key'] = "YOUR API KEY"
|
||||||
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
||||||
#config.api_key_prefix['api_key'] = "Token"
|
#config.api_key_prefix['api_key'] = "Token"
|
||||||
|
|
||||||
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
|
config.access_token = "YOUR ACCESS TOKEN"
|
||||||
end
|
end
|
||||||
|
|
||||||
api = Petstore::PetApi.new
|
api = Petstore::PetApi.new
|
||||||
@ -318,7 +318,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
|
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
### HTTP reuqest headers
|
### HTTP reuqest headers
|
||||||
|
|
||||||
@ -339,13 +339,13 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
|||||||
require 'petstore'
|
require 'petstore'
|
||||||
|
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
|
||||||
config.access_token = "YOUR ACCESS TOKEN"
|
|
||||||
|
|
||||||
# Configure API key authorization: api_key
|
# Configure API key authorization: api_key
|
||||||
config.api_key['api_key'] = "YOUR API KEY"
|
config.api_key['api_key'] = "YOUR API KEY"
|
||||||
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
||||||
#config.api_key_prefix['api_key'] = "Token"
|
#config.api_key_prefix['api_key'] = "Token"
|
||||||
|
|
||||||
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
|
config.access_token = "YOUR ACCESS TOKEN"
|
||||||
end
|
end
|
||||||
|
|
||||||
api = Petstore::PetApi.new
|
api = Petstore::PetApi.new
|
||||||
@ -373,7 +373,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
|
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
### HTTP reuqest headers
|
### HTTP reuqest headers
|
||||||
|
|
||||||
@ -394,13 +394,13 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
|||||||
require 'petstore'
|
require 'petstore'
|
||||||
|
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
|
||||||
config.access_token = "YOUR ACCESS TOKEN"
|
|
||||||
|
|
||||||
# Configure API key authorization: api_key
|
# Configure API key authorization: api_key
|
||||||
config.api_key['api_key'] = "YOUR API KEY"
|
config.api_key['api_key'] = "YOUR API KEY"
|
||||||
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
||||||
#config.api_key_prefix['api_key'] = "Token"
|
#config.api_key_prefix['api_key'] = "Token"
|
||||||
|
|
||||||
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
|
config.access_token = "YOUR ACCESS TOKEN"
|
||||||
end
|
end
|
||||||
|
|
||||||
api = Petstore::PetApi.new
|
api = Petstore::PetApi.new
|
||||||
@ -428,7 +428,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
|
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
|
||||||
|
|
||||||
### HTTP reuqest headers
|
### HTTP reuqest headers
|
||||||
|
|
||||||
|
@ -218,15 +218,15 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w
|
|||||||
require 'petstore'
|
require 'petstore'
|
||||||
|
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
# Configure API key authorization: test_api_key_query
|
|
||||||
config.api_key['test_api_key_query'] = "YOUR API KEY"
|
|
||||||
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
|
||||||
#config.api_key_prefix['test_api_key_query'] = "Token"
|
|
||||||
|
|
||||||
# Configure API key authorization: test_api_key_header
|
# Configure API key authorization: test_api_key_header
|
||||||
config.api_key['test_api_key_header'] = "YOUR API KEY"
|
config.api_key['test_api_key_header'] = "YOUR API KEY"
|
||||||
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
||||||
#config.api_key_prefix['test_api_key_header'] = "Token"
|
#config.api_key_prefix['test_api_key_header'] = "Token"
|
||||||
|
|
||||||
|
# Configure API key authorization: test_api_key_query
|
||||||
|
config.api_key['test_api_key_query'] = "YOUR API KEY"
|
||||||
|
# Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to nil)
|
||||||
|
#config.api_key_prefix['test_api_key_query'] = "Token"
|
||||||
end
|
end
|
||||||
|
|
||||||
api = Petstore::StoreApi.new
|
api = Petstore::StoreApi.new
|
||||||
@ -254,7 +254,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
|
[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query)
|
||||||
|
|
||||||
### HTTP reuqest headers
|
### HTTP reuqest headers
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ This can only be done by the logged in user.
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
@ -68,8 +66,6 @@ Creates list of users with given input array
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
@ -113,8 +109,6 @@ Creates list of users with given input array
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
@ -158,8 +152,6 @@ This can only be done by the logged in user.
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
Petstore.configure do |config|
|
Petstore.configure do |config|
|
||||||
# Configure HTTP basic authorization: test_http_basic
|
# Configure HTTP basic authorization: test_http_basic
|
||||||
config.username = 'YOUR USERNAME'
|
config.username = 'YOUR USERNAME'
|
||||||
@ -208,8 +200,6 @@ Get user by user name
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing.
|
username = "username_example" # [String] The name that needs to be fetched. Use user1 for testing.
|
||||||
@ -217,7 +207,6 @@ username = "username_example" # [String] The name that needs to be fetched. Use
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
result = api.get_user_by_name(username)
|
result = api.get_user_by_name(username)
|
||||||
p result
|
|
||||||
rescue Petstore::ApiError => e
|
rescue Petstore::ApiError => e
|
||||||
puts "Exception when calling get_user_by_name: #{e}"
|
puts "Exception when calling get_user_by_name: #{e}"
|
||||||
end
|
end
|
||||||
@ -253,8 +242,6 @@ Logs user into the system
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
@ -264,7 +251,6 @@ opts = {
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
result = api.login_user(opts)
|
result = api.login_user(opts)
|
||||||
p result
|
|
||||||
rescue Petstore::ApiError => e
|
rescue Petstore::ApiError => e
|
||||||
puts "Exception when calling login_user: #{e}"
|
puts "Exception when calling login_user: #{e}"
|
||||||
end
|
end
|
||||||
@ -301,8 +287,6 @@ Logs out current logged in user session
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -339,8 +323,6 @@ This can only be done by the logged in user.
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
require 'petstore'
|
|
||||||
|
|
||||||
api = Petstore::UserApi.new
|
api = Petstore::UserApi.new
|
||||||
|
|
||||||
username = "username_example" # [String] name that need to be deleted
|
username = "username_example" # [String] name that need to be deleted
|
||||||
|
@ -33,7 +33,7 @@ module Petstore
|
|||||||
|
|
||||||
def initialize(config = Configuration.default)
|
def initialize(config = Configuration.default)
|
||||||
@config = config
|
@config = config
|
||||||
@user_agent = "ruby-swagger-#{VERSION}"
|
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
||||||
@default_headers = {
|
@default_headers = {
|
||||||
'Content-Type' => "application/json",
|
'Content-Type' => "application/json",
|
||||||
'User-Agent' => @user_agent
|
'User-Agent' => @user_agent
|
||||||
|
@ -171,6 +171,13 @@ module Petstore
|
|||||||
key: 'x-test_api_client_id',
|
key: 'x-test_api_client_id',
|
||||||
value: api_key_with_prefix('x-test_api_client_id')
|
value: api_key_with_prefix('x-test_api_client_id')
|
||||||
},
|
},
|
||||||
|
'test_http_basic' =>
|
||||||
|
{
|
||||||
|
type: 'basic',
|
||||||
|
in: 'header',
|
||||||
|
key: 'Authorization',
|
||||||
|
value: basic_auth_token
|
||||||
|
},
|
||||||
'test_api_client_secret' =>
|
'test_api_client_secret' =>
|
||||||
{
|
{
|
||||||
type: 'api_key',
|
type: 'api_key',
|
||||||
|
@ -36,17 +36,7 @@ describe 'InlineResponse200' do
|
|||||||
@instance.should be_a(Petstore::InlineResponse200)
|
@instance.should be_a(Petstore::InlineResponse200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe 'test attribute "photo_urls"' do
|
describe 'test attribute "tags"' do
|
||||||
it 'should work' do
|
|
||||||
# assertion here
|
|
||||||
# should be_a()
|
|
||||||
# should be_nil
|
|
||||||
# should ==
|
|
||||||
# should_not ==
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'test attribute "name"' do
|
|
||||||
it 'should work' do
|
it 'should work' do
|
||||||
# assertion here
|
# assertion here
|
||||||
# should be_a()
|
# should be_a()
|
||||||
@ -76,7 +66,7 @@ describe 'InlineResponse200' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'test attribute "tags"' do
|
describe 'test attribute "status"' do
|
||||||
it 'should work' do
|
it 'should work' do
|
||||||
# assertion here
|
# assertion here
|
||||||
# should be_a()
|
# should be_a()
|
||||||
@ -86,7 +76,17 @@ describe 'InlineResponse200' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'test attribute "status"' do
|
describe 'test attribute "name"' do
|
||||||
|
it 'should work' do
|
||||||
|
# assertion here
|
||||||
|
# should be_a()
|
||||||
|
# should be_nil
|
||||||
|
# should ==
|
||||||
|
# should_not ==
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'test attribute "photo_urls"' do
|
||||||
it 'should work' do
|
it 'should work' do
|
||||||
# assertion here
|
# assertion here
|
||||||
# should be_a()
|
# should be_a()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user