Class: Keiyaku::Client
- Inherits:
-
Object
- Object
- Keiyaku::Client
- Defined in:
- lib/keiyaku/runtime.rb,
sig/keiyaku.rbs
Overview
Base class for generated clients. The generated subclass contains one declaration per operation and nothing else.
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#base_url ⇒ String
readonly
Returns the value of attribute base_url.
Class Method Summary collapse
- .default_security ⇒ Array[Array[Symbol]]
- .delete ⇒ void
- .get ⇒ void
- .head ⇒ void
- .inherited(subclass) ⇒ Object
-
.operation(verb, name, template, query: [], deep_object: [], header: {}, explode: [], required: [], body: nil, form: nil, multipart: nil, content_type: nil, body_required: false, into: nil, errors: {}, security: :inherit) ⇒ Object
Declare one operation, and define a real method for it.
- .options ⇒ void
- .patch ⇒ void
- .post ⇒ void
- .put ⇒ void
-
.requirement(declared) ⇒ Object
A security requirement is a list of alternatives, each of which is a set of schemes that all have to be satisfied: OpenAPI's OR of ANDs.
-
.security(schemes = nil, default: nil) ⇒ Object
The document's security schemes, by the name it gave them, plus the requirement that holds for an operation which does not state its own.
- .server(url = nil) ⇒ String?
-
.unsupported(name, reason) ⇒ Object
An operation the generator could not build correctly.
Instance Method Summary collapse
-
#initialize(base_url: nil, auth: nil, adapter: nil, timeout: 15, retries: 0, logger: nil) ⇒ Client
constructor
auth:is credentials by scheme name — a bare value only where the document declares one scheme, since with two there is nothing to say which it is.
Constructor Details
#initialize(base_url: nil, auth: nil, adapter: nil, timeout: 15, retries: 0, logger: nil) ⇒ Client
auth: is credentials by scheme name — a bare value only where the
document declares one scheme, since with two there is nothing to say
which it is.
211 |
# File 'sig/keiyaku.rbs', line 211
def initialize: (
|
Class Attribute Details
.operations ⇒ Hash[Symbol, Hash[Symbol, untyped]] (readonly)
176 |
# File 'sig/keiyaku.rbs', line 176
def self.operations: () -> Hash[Symbol, Hash[Symbol, untyped]]
|
Instance Attribute Details
#base_url ⇒ String (readonly)
Returns the value of attribute base_url.
206 207 208 |
# File 'sig/keiyaku.rbs', line 206 def base_url @base_url end |
Class Method Details
.default_security ⇒ Array[Array[Symbol]]
182 |
# File 'sig/keiyaku.rbs', line 182
def self.default_security: () -> Array[Array[Symbol]]
|
.delete ⇒ void
This method returns an undefined value.
192 |
# File 'sig/keiyaku.rbs', line 192
def self.delete: (Symbol name, String template, **untyped) -> void
|
.get ⇒ void
This method returns an undefined value.
188 |
# File 'sig/keiyaku.rbs', line 188
def self.get: (Symbol name, String template, **untyped) -> void
|
.head ⇒ void
This method returns an undefined value.
193 |
# File 'sig/keiyaku.rbs', line 193
def self.head: (Symbol name, String template, **untyped) -> void
|
.inherited(subclass) ⇒ Object
557 558 559 560 561 562 563 |
# File 'lib/keiyaku/runtime.rb', line 557 def inherited(subclass) super subclass.instance_variable_set(:@operations, operations&.dup || {}) subclass.instance_variable_set(:@server, @server) subclass.instance_variable_set(:@security, @security) subclass.instance_variable_set(:@default_security, @default_security) end |
.operation(verb, name, template, query: [], deep_object: [], header: {}, explode: [], required: [], body: nil, form: nil, multipart: nil, content_type: nil, body_required: false, into: nil, errors: {}, security: :inherit) ⇒ Object
Declare one operation, and define a real method for it.
required: names the query and header parameters a caller has to
pass, by the name the document gave them — which for a header is the
name on the wire rather than the Ruby one it arrives under:
get :find, "/pets", query: %i[status limit], required: %i[status]
deep_object: names the query parameters the document gave
style: deepObject, which go out spelled a key at a time:
get :list, "/widgets", query: %i[filter], deep_object: %w[filter]
explode: names the path and header parameters the document wrote
explode on, which is the one thing that cannot be read off the value
itself: an object goes out as role=admin,name=alex where it was said
and as role,admin,name,alex where it was not.
620 |
# File 'lib/keiyaku/runtime.rb', line 620
def self.operation: (
|
.options ⇒ void
This method returns an undefined value.
194 |
# File 'sig/keiyaku.rbs', line 194
def self.options: (Symbol name, String template, **untyped) -> void
|
.patch ⇒ void
This method returns an undefined value.
191 |
# File 'sig/keiyaku.rbs', line 191
def self.patch: (Symbol name, String template, **untyped) -> void
|
.post ⇒ void
This method returns an undefined value.
189 |
# File 'sig/keiyaku.rbs', line 189
def self.post: (Symbol name, String template, **untyped) -> void
|
.put ⇒ void
This method returns an undefined value.
190 |
# File 'sig/keiyaku.rbs', line 190
def self.put: (Symbol name, String template, **untyped) -> void
|
.requirement(declared) ⇒ Object
A security requirement is a list of alternatives, each of which is a
set of schemes that all have to be satisfied: OpenAPI's OR of ANDs.
false and [] are the operation that takes no credentials at all,
which is not the same as one that does not say.
186 |
# File 'sig/keiyaku.rbs', line 186
def self.requirement: (untyped) -> Array[Array[Symbol]]
|
.security(schemes = nil, default: nil) ⇒ Object
The document's security schemes, by the name it gave them, plus the requirement that holds for an operation which does not state its own.
security({ api_key: { header: "api_key" }, petstore_auth: :bearer },
default: :api_key)
A scheme is :bearer, :basic, or one of { header: }, { query: },
{ cookie: } naming where an API key goes. Credentials are then given
by scheme name, because a document that declares two has no single
"the" credential and picking one for the caller is how a client ends
up sending the wrong header to every operation it has.
181 |
# File 'sig/keiyaku.rbs', line 181
def self.security: (?Hash[Symbol | String, untyped] schemes, ?default: untyped) -> untyped
|
.server(url = nil) ⇒ String?
177 |
# File 'sig/keiyaku.rbs', line 177
def self.server: (?String?) -> String?
|
.unsupported(name, reason) ⇒ Object
An operation the generator could not build correctly. Declaring it keeps the omission visible instead of leaving a silent hole in the client.
681 |
# File 'lib/keiyaku/runtime.rb', line 681
def self.unsupported: (Symbol name, String reason) -> void
|