Skip to content

Commit 00f15c8

Browse files
committed
Checkpoint
1 parent cefa553 commit 00f15c8

9 files changed

Lines changed: 54 additions & 20 deletions

File tree

docs/playground/lib/example_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def swap_output(temp_public, temp_examples)
5555
end
5656

5757
def generated_dirs
58-
Apiwork::API.all.map do |api_class|
58+
Apiwork::API.values.map do |api_class|
5959
api_class.path.delete_prefix('/').underscore.dasherize
6060
end
6161
end
@@ -76,7 +76,7 @@ def eager_load_schemas
7676
end
7777

7878
def each_api
79-
Apiwork::API.all.sort_by(&:path).each do |api_class|
79+
Apiwork::API.values.sort_by(&:path).each do |api_class|
8080
namespace = api_class.path.delete_prefix('/').underscore
8181
metadata = metadata_for(namespace)
8282
yield api_class, namespace, metadata

docs/reference/adapter-render-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929

3030
```ruby
3131
def render_collection(collection, schema_class, state)
32-
response = { data: collection.map { |r| serialize(r) } }
32+
response = { data: collection.map { |record| serialize(record) } }
3333
response[:cache] = true if state.action.get?
3434
response
3535
end

docs/reference/contract-request.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ next: false
1010

1111
Defines query params and body for a request.
1212

13-
Returns [Object](object) via `query` and `body`.
13+
Returns [Contract::Object](contract-object) via `query` and `body`.
1414

1515
## Instance Methods
1616

1717
### #body
1818

1919
`#body(&block)`
2020

21-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/request.rb#L59)
21+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/request.rb#L57)
2222

2323
Defines the request body for this request.
2424

@@ -47,7 +47,7 @@ end
4747

4848
`#query(&block)`
4949

50-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/request.rb#L35)
50+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/request.rb#L33)
5151

5252
Defines query parameters for this request.
5353

docs/reference/contract-response.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Returns [Object](object) via `body`.
1818

1919
`#body(&block)`
2020

21-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L65)
21+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L64)
2222

2323
Defines the response body for this response.
2424

@@ -48,7 +48,7 @@ end
4848

4949
`#no_content!`
5050

51-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L47)
51+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L46)
5252

5353
Declares this action returns 204 No Content.
5454

@@ -77,7 +77,7 @@ end
7777

7878
`#no_content?`
7979

80-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L28)
80+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/contract/response.rb#L27)
8181

8282
Returns true if this response is 204 No Content.
8383

docs/reference/export-base.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Apiwork::Export.register(ProtobufExport)
4949

5050
`.export_name(name = nil)`
5151

52-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L43)
52+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L51)
5353

5454
The export name.
5555

@@ -69,7 +69,7 @@ The export name.
6969

7070
`.file_extension(value = nil)`
7171

72-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L85)
72+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L88)
7373

7474
The file extension for string exports.
7575

@@ -144,7 +144,7 @@ end
144144

145145
`.output(type = nil)`
146146

147-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L52)
147+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L60)
148148

149149
Declares the output type for this export.
150150

@@ -162,7 +162,7 @@ Declares the output type for this export.
162162

163163
`#data`
164164

165-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L262)
165+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L242)
166166

167167
The API introspection facade.
168168

@@ -182,7 +182,7 @@ This is the primary interface for accessing introspection data in export generat
182182

183183
`#generate`
184184

185-
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L206)
185+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L186)
186186

187187
Generates the export output.
188188

@@ -199,3 +199,37 @@ to types, enums, resources, actions, and other introspection data.
199199
- [Introspection::API](introspection-api)
200200

201201
---
202+
203+
### #key_format
204+
205+
`#key_format`
206+
207+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L250)
208+
209+
The key format for this export.
210+
211+
**Returns**
212+
213+
`Symbol`
214+
215+
---
216+
217+
### #transform_key
218+
219+
`#transform_key(key)`
220+
221+
[GitHub](https://github.com/skiftle/apiwork/blob/main/lib/apiwork/export/base.rb#L259)
222+
223+
Transforms a key according to the configured key format.
224+
225+
**Parameters**
226+
227+
| Name | Type | Description |
228+
|------|------|-------------|
229+
| `key` | `String, Symbol` | the key to transform |
230+
231+
**Returns**
232+
233+
`String`
234+
235+
---

lib/apiwork/adapter/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def register_api(registrar, capabilities)
6666
# if action.collection?
6767
# definition.request do
6868
# query do
69-
# integer :page, optional: true
69+
# integer? :page
7070
# end
7171
# end
7272
# end

lib/apiwork/contract/action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def raises(*error_code_keys)
163163
# action :create do
164164
# request do
165165
# query do
166-
# boolean :dry_run, optional: true
166+
# boolean? :dry_run
167167
# end
168168
# body do
169169
# string :title

lib/apiwork/contract/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def import(contract_class, as:)
313313
# action :show do
314314
# request do
315315
# query do
316-
# string :include, optional: true
316+
# string? :include
317317
# end
318318
# end
319319
# response do

lib/apiwork/contract/request.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Contract
55
# @api public
66
# Defines query params and body for a request.
77
#
8-
# Returns {Object} via `query` and `body`.
8+
# Returns {Contract::Object} via `query` and `body`.
99
class Request
1010
attr_reader :action_name,
1111
:contract_class
@@ -27,8 +27,8 @@ def initialize(contract_class, action_name)
2727
#
2828
# @example
2929
# query do
30-
# integer :page, optional: true
31-
# string :status, enum: :status, optional: true
30+
# integer? :page
31+
# string? :status, enum: :status
3232
# end
3333
def query(&block)
3434
if block

0 commit comments

Comments
 (0)