forked from loafle/openapi-generator-original
Ruby docs: add sample code of configuring auths
This commit is contained in:
parent
1df0923525
commit
d274af4d4a
@ -18,7 +18,20 @@ Method | HTTP request | Description
|
||||
{{notes}}{{/notes}}
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
```ruby{{#hasAuthMethods}}
|
||||
{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}
|
||||
# Configure HTTP basic authorization: {{{name}}}
|
||||
config.username = 'YOUR USERNAME'
|
||||
config.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}}
|
||||
# Configure API key authorization: {{{name}}}
|
||||
config.api_key['{{{keyParamName}}}'] = "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['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}}
|
||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||
config.access_token = "YOUR ACCESS TOKEN"{{/isOAuth}}
|
||||
{{/authMethods}}end
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
api = {{{moduleName}}}::{{{classname}}}.new{{#hasParams}}
|
||||
{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}}
|
||||
{{{paramName}}} = {{{example}}} # [{{{dataType}}}] {{{description}}}
|
||||
|
@ -6,7 +6,7 @@ Version: 1.0.0
|
||||
|
||||
Automatically generated by the Ruby Swagger Codegen project:
|
||||
|
||||
- Build date: 2016-03-11T15:13:56.730+08:00
|
||||
- Build date: 2016-03-11T18:59:01.854+08:00
|
||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||
|
||||
## Installation
|
||||
|
@ -26,6 +26,11 @@ Add a new pet to the store
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
opts = {
|
||||
@ -69,6 +74,11 @@ Fake endpoint to test byte array in body parameter for adding a new pet to the s
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
opts = {
|
||||
@ -112,6 +122,11 @@ Deletes a pet
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = 789 # [Integer] Pet id to delete
|
||||
@ -158,6 +173,11 @@ Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
opts = {
|
||||
@ -201,6 +221,11 @@ Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
opts = {
|
||||
@ -244,6 +269,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
|
||||
# Configure API key authorization: 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)
|
||||
#config.api_key_prefix['api_key'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = 789 # [Integer] ID of pet that needs to be fetched
|
||||
@ -286,6 +321,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
|
||||
# Configure API key authorization: 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)
|
||||
#config.api_key_prefix['api_key'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = 789 # [Integer] ID of pet that needs to be fetched
|
||||
@ -328,6 +373,16 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API erro
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
|
||||
# Configure API key authorization: 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)
|
||||
#config.api_key_prefix['api_key'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = 789 # [Integer] ID of pet that needs to be fetched
|
||||
@ -370,6 +425,11 @@ Update an existing pet
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
opts = {
|
||||
@ -413,6 +473,11 @@ Updates a pet in the store with form data
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = "pet_id_example" # [String] ID of pet that needs to be updated
|
||||
@ -461,6 +526,11 @@ uploads an image
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = "YOUR ACCESS TOKEN"
|
||||
end
|
||||
|
||||
api = Petstore::PetApi.new
|
||||
|
||||
pet_id = 789 # [Integer] ID of pet to update
|
||||
|
@ -63,6 +63,18 @@ A single status value can be provided as a string
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: test_api_client_id
|
||||
config.api_key['x-test_api_client_id'] = "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['x-test_api_client_id'] = "Token"
|
||||
|
||||
# Configure API key authorization: test_api_client_secret
|
||||
config.api_key['x-test_api_client_secret'] = "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['x-test_api_client_secret'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::StoreApi.new
|
||||
|
||||
opts = {
|
||||
@ -106,6 +118,13 @@ Returns a map of status codes to quantities
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: 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)
|
||||
#config.api_key_prefix['api_key'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::StoreApi.new
|
||||
|
||||
begin
|
||||
@ -142,6 +161,13 @@ Returns an arbitrary object which is actually a map of status codes to quantitie
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: 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)
|
||||
#config.api_key_prefix['api_key'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::StoreApi.new
|
||||
|
||||
begin
|
||||
@ -178,6 +204,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values w
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
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
|
||||
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)
|
||||
#config.api_key_prefix['test_api_key_header'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::StoreApi.new
|
||||
|
||||
order_id = "order_id_example" # [String] ID of pet that needs to be fetched
|
||||
@ -220,6 +258,18 @@ Place an order for a pet
|
||||
|
||||
### Example
|
||||
```ruby
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: test_api_client_id
|
||||
config.api_key['x-test_api_client_id'] = "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['x-test_api_client_id'] = "Token"
|
||||
|
||||
# Configure API key authorization: test_api_client_secret
|
||||
config.api_key['x-test_api_client_secret'] = "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['x-test_api_client_secret'] = "Token"
|
||||
end
|
||||
|
||||
api = Petstore::StoreApi.new
|
||||
|
||||
opts = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user