API
Modules
Class Methods
.define
.define(base_path, &block)
Defines a new API at the given base path.
This is the main entry point for creating an Apiwork API. The block receives an API recorder for defining resources, types, and configuration.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
base_path | String | The API base path. |
Returns
Class<API::Base>
Example: Basic API
ruby
Apiwork::API.define '/api/v1' do
resources :users
resources :posts
endExample: With configuration
ruby
Apiwork::API.define '/api/v1' do
key_format :camel
resources :invoices
end.find
.find(base_path)
Finds an API by base path.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
base_path | String | The API base path. |
Returns
Class<API::Base>, nil
See also
Example
ruby
Apiwork::API.find('/api/v1').find!
.find!(base_path)
Finds an API by base path.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
base_path | String | The API base path. |
Returns
Class<API::Base>
See also
Example
ruby
Apiwork::API.find!('/api/v1').introspect
.introspect(base_path, locale: nil)
The introspection data for an API.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
base_path | String | The API base path. | |
locale | Symbol, nil | nil | The locale for descriptions. |
Returns
Example
ruby
Apiwork::API.introspect('/api/v1')