openapi_kit 0.1.0.pre.2 → 0.1.0.pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -12
  3. data/lib/openapi_kit/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d304ba17a6fa760d97ee15f5755e8986723bb44761bb4508413d84da2c45925
4
- data.tar.gz: e428d43ce8dce01bbb48f9929b0173de72b2bd2789e5e1df8dfaf402b1a17a8a
3
+ metadata.gz: 613a75911e2ca7e79f0eaf2efaf73e8fb5010b80ee1198e80fb7e2d364015d11
4
+ data.tar.gz: 2ecbfb34c60742a6b98e3c1cd29cf235f8a8bacd0ae8d647d952dc4ddce60ac8
5
5
  SHA512:
6
- metadata.gz: 4d24fd4aa84db299e0eeaab6869c51305243e35c3d682824cdb72d4c80777f6125f6165a259ecfb290c61fa2de6d703c3e84b7b81b2871d2ef1d70e61221bc76
7
- data.tar.gz: e24da0aa1ce7b436160f00da9f407c506a0ee1f391e53d3d0408a12db7dba42ec6672ed3a9b2f930fc0142c780ec937bda156efa359e3d4daaad8662fe355dbd
6
+ metadata.gz: b50ef496efb12a30f02420d7c7f0624b34fb4bcae6ccb84883fb34fa69cb0cb7c033c23da45189458b432dcefa30f946172497dfa24e257f4f52ce33132b1efa
7
+ data.tar.gz: ce716d3ace4b5710b3ff8eb8be23b7dc42387208649b2fd398ef1bda64c328405e6acc32cbf5450761f539ba4df779915694d15402447ac6cd6c5eda19112063
data/README.md CHANGED
@@ -28,7 +28,7 @@ end
28
28
  ```yaml
29
29
  # openapi_kit.yml
30
30
  spec: openapi/petstore.yaml
31
- output: app/api
31
+ output: app/api/petstore/v1
32
32
  modules: [Petstore, V1]
33
33
  controller_base: Api::BaseController
34
34
  principal: "::Petstore::Principal"
@@ -37,8 +37,8 @@ principal: "::Petstore::Principal"
37
37
  | Option | Meaning |
38
38
  | --- | --- |
39
39
  | `spec` | root OpenAPI document, resolved relative to this file |
40
- | `output` | directory the tree is written to, which openapi_kit owns |
41
- | `modules` | namespace for every generated constant, so `Petstore::V1::Types::Pet` |
40
+ | `output` | directory the tree is written into, which openapi_kit owns |
41
+ | `modules` | namespace every generated constant is declared in, so `Petstore::V1::Types::Pet` |
42
42
  | `controller_base` | class the generated controllers inherit from |
43
43
  | `principal` | the class a successful authentication produces |
44
44
  | `type_mappings` | your Ruby type for a `type:format` pair |
@@ -57,13 +57,16 @@ app/api/petstore/v1/registry.rb
57
57
  app/api/petstore/v1/routes.rb
58
58
  ```
59
59
 
60
- One constant per file at the path that constant implies, so Rails autoloads it. Each run
61
- wipes `output`, but only after checking openapi_kit generated every `.rb` in it.
60
+ Nothing is written outside `output`, and `modules` decides only what the files declare. One
61
+ constant per file at the path that constant implies, counting from `output`, so laying the
62
+ directory out to match the namespace is what lets Rails autoload it. Each run wipes
63
+ `output`, but only after checking openapi_kit generated every `.rb` in it.
62
64
 
63
65
  ## Integrating with Rails
64
66
 
65
- **Autoload the output**, if it is not already under `app/`. An acronym in `modules`
66
- becomes a directory, so it needs an inflection like any other acronym constant.
67
+ **Autoload the tree**, if it is not already under `app/`. The root is the directory
68
+ `modules` counts from, not `output` itself. An acronym in `modules` is a directory like any
69
+ other, so it needs an inflection.
67
70
 
68
71
  ```ruby
69
72
  # config/application.rb
@@ -125,15 +128,15 @@ module Api
125
128
  end
126
129
  ```
127
130
 
128
- **Assign the registry.** openapi_kit generates a `Registry` struct with one slot per handler and
129
- authenticator, and controllers read it from `Petstore::V1.registry`. Rails instantiates
130
- controllers itself, so they cannot be handed one. Omit a slot, or pass something that does
131
- not implement its interface, and it does not compile.
131
+ **Assign the registry.** openapi_kit generates a `Registry` struct with one slot per handler
132
+ and authenticator, and controllers read the one you assigned. Rails instantiates controllers
133
+ itself, so they cannot be handed one. Omit a slot, or pass something that does not
134
+ implement its interface, and it does not compile.
132
135
 
133
136
  ```ruby
134
137
  # config/initializers/openapi_kit.rb
135
138
  Rails.application.config.to_prepare do
136
- Petstore::V1.registry = Petstore::V1::Registry.new(
139
+ Petstore::V1::Registry.instance = Petstore::V1::Registry.new(
137
140
  pets: PetsHandler.new(repo: PetRepo.new),
138
141
  system: SystemHandler.new,
139
142
  bearer_auth: BearerAuthenticator.new(decoder: TokenDecoder.new)
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module OpenAPIKit
5
- VERSION = "0.1.0.pre.2"
5
+ VERSION = "0.1.0.pre.3"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.2
4
+ version: 0.1.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Robertson