grape-swagger-rails 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ffd522dac6b7efe49bc024272c280fd715108d6b4fe974b4ecb197702ddd0c5
4
- data.tar.gz: d93eda34ff295a2387005d93a82d8c3606e2568979ae82e3a512455bcf1a2685
3
+ metadata.gz: 61a592b658be0f0b08a98137d907c771b4444627d3da072b40b73cfe4ea40773
4
+ data.tar.gz: c44bec534d280e3d579ecb71f4f0f63b722f672538b5b45495c6c5ca107da168
5
5
  SHA512:
6
- metadata.gz: 9f02aee03ef70e0fbfba49c2c42f86c73279fa29d3f15f5524033f270a1c8a452c30f2c9d2ae3595abcb992125fe1db2e515cce0a7dec7827dbd481acba0ae4e
7
- data.tar.gz: a4ad6d3529fac3b4f5bdf0360b45b5cfa0a4bc24a17dc59ffd8a519d8edc3dd9bcc07a7f8de394c50858854cd1d431f3e41dfc3d9afd79db77ae0a01f4ec07a4
6
+ metadata.gz: 1fd25759115054c6885fdb7c31a8dd9be252c0b82f6935d50c639d37e349d1149773302db8265f2569799ba99e87f74f63827d41a25af9b6b14b4ecee7c804e1
7
+ data.tar.gz: cfedf854908cda46fd6ba7d55bb35fc02d5e65c35034251e12e90abaafe8889f137703564aec572acd470fe3e4d1574aa1d7185ad098fcc58dc9ca4c7b11421d
@@ -1,5 +1,9 @@
1
1
  name: Frontend
2
- on: [push, pull_request]
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
3
7
  jobs:
4
8
  frontend:
5
9
  runs-on: ubuntu-latest
@@ -18,4 +22,8 @@ jobs:
18
22
  - name: Build frontend
19
23
  run: yarn build:frontend
20
24
  - name: Check compiled output is committed
21
- run: git diff --exit-code app/assets/javascripts/grape_swagger_rails/index.js
25
+ run: |
26
+ git diff --exit-code \
27
+ app/assets/javascripts/grape_swagger_rails/index.js \
28
+ app/assets/javascripts/grape_swagger_rails/index.min.js \
29
+ app/assets/javascripts/grape_swagger_rails/index.min.js.map
@@ -1,5 +1,9 @@
1
1
  name: Tests
2
- on: [push, pull_request]
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
3
7
  jobs:
4
8
  test:
5
9
  runs-on: ubuntu-latest
data/.pnp.cjs CHANGED
@@ -28,16 +28,287 @@ const RAW_RUNTIME_STATE =
28
28
  [null, {\
29
29
  "packageLocation": "./",\
30
30
  "packageDependencies": [\
31
+ ["esbuild", "npm:0.25.12"],\
31
32
  ["grape-swagger-rails", "workspace:."],\
32
33
  ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"]\
33
34
  ],\
34
35
  "linkType": "SOFT"\
35
36
  }]\
36
37
  ]],\
38
+ ["@esbuild/aix-ppc64", [\
39
+ ["npm:0.25.12", {\
40
+ "packageLocation": "./.yarn/unplugged/@esbuild-aix-ppc64-npm-0.25.12-8c22abd617/node_modules/@esbuild/aix-ppc64/",\
41
+ "packageDependencies": [\
42
+ ["@esbuild/aix-ppc64", "npm:0.25.12"]\
43
+ ],\
44
+ "linkType": "HARD"\
45
+ }]\
46
+ ]],\
47
+ ["@esbuild/android-arm", [\
48
+ ["npm:0.25.12", {\
49
+ "packageLocation": "./.yarn/unplugged/@esbuild-android-arm-npm-0.25.12-30cfcd9e3d/node_modules/@esbuild/android-arm/",\
50
+ "packageDependencies": [\
51
+ ["@esbuild/android-arm", "npm:0.25.12"]\
52
+ ],\
53
+ "linkType": "HARD"\
54
+ }]\
55
+ ]],\
56
+ ["@esbuild/android-arm64", [\
57
+ ["npm:0.25.12", {\
58
+ "packageLocation": "./.yarn/unplugged/@esbuild-android-arm64-npm-0.25.12-00cec8936f/node_modules/@esbuild/android-arm64/",\
59
+ "packageDependencies": [\
60
+ ["@esbuild/android-arm64", "npm:0.25.12"]\
61
+ ],\
62
+ "linkType": "HARD"\
63
+ }]\
64
+ ]],\
65
+ ["@esbuild/android-x64", [\
66
+ ["npm:0.25.12", {\
67
+ "packageLocation": "./.yarn/unplugged/@esbuild-android-x64-npm-0.25.12-f0cc7556ec/node_modules/@esbuild/android-x64/",\
68
+ "packageDependencies": [\
69
+ ["@esbuild/android-x64", "npm:0.25.12"]\
70
+ ],\
71
+ "linkType": "HARD"\
72
+ }]\
73
+ ]],\
74
+ ["@esbuild/darwin-arm64", [\
75
+ ["npm:0.25.12", {\
76
+ "packageLocation": "./.yarn/unplugged/@esbuild-darwin-arm64-npm-0.25.12-2a5a9f9710/node_modules/@esbuild/darwin-arm64/",\
77
+ "packageDependencies": [\
78
+ ["@esbuild/darwin-arm64", "npm:0.25.12"]\
79
+ ],\
80
+ "linkType": "HARD"\
81
+ }]\
82
+ ]],\
83
+ ["@esbuild/darwin-x64", [\
84
+ ["npm:0.25.12", {\
85
+ "packageLocation": "./.yarn/unplugged/@esbuild-darwin-x64-npm-0.25.12-157b2f4f8a/node_modules/@esbuild/darwin-x64/",\
86
+ "packageDependencies": [\
87
+ ["@esbuild/darwin-x64", "npm:0.25.12"]\
88
+ ],\
89
+ "linkType": "HARD"\
90
+ }]\
91
+ ]],\
92
+ ["@esbuild/freebsd-arm64", [\
93
+ ["npm:0.25.12", {\
94
+ "packageLocation": "./.yarn/unplugged/@esbuild-freebsd-arm64-npm-0.25.12-82171eee7e/node_modules/@esbuild/freebsd-arm64/",\
95
+ "packageDependencies": [\
96
+ ["@esbuild/freebsd-arm64", "npm:0.25.12"]\
97
+ ],\
98
+ "linkType": "HARD"\
99
+ }]\
100
+ ]],\
101
+ ["@esbuild/freebsd-x64", [\
102
+ ["npm:0.25.12", {\
103
+ "packageLocation": "./.yarn/unplugged/@esbuild-freebsd-x64-npm-0.25.12-464a938fa1/node_modules/@esbuild/freebsd-x64/",\
104
+ "packageDependencies": [\
105
+ ["@esbuild/freebsd-x64", "npm:0.25.12"]\
106
+ ],\
107
+ "linkType": "HARD"\
108
+ }]\
109
+ ]],\
110
+ ["@esbuild/linux-arm", [\
111
+ ["npm:0.25.12", {\
112
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-arm-npm-0.25.12-dd07033e1a/node_modules/@esbuild/linux-arm/",\
113
+ "packageDependencies": [\
114
+ ["@esbuild/linux-arm", "npm:0.25.12"]\
115
+ ],\
116
+ "linkType": "HARD"\
117
+ }]\
118
+ ]],\
119
+ ["@esbuild/linux-arm64", [\
120
+ ["npm:0.25.12", {\
121
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-arm64-npm-0.25.12-a5aaa0e70e/node_modules/@esbuild/linux-arm64/",\
122
+ "packageDependencies": [\
123
+ ["@esbuild/linux-arm64", "npm:0.25.12"]\
124
+ ],\
125
+ "linkType": "HARD"\
126
+ }]\
127
+ ]],\
128
+ ["@esbuild/linux-ia32", [\
129
+ ["npm:0.25.12", {\
130
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-ia32-npm-0.25.12-3b5addbfbb/node_modules/@esbuild/linux-ia32/",\
131
+ "packageDependencies": [\
132
+ ["@esbuild/linux-ia32", "npm:0.25.12"]\
133
+ ],\
134
+ "linkType": "HARD"\
135
+ }]\
136
+ ]],\
137
+ ["@esbuild/linux-loong64", [\
138
+ ["npm:0.25.12", {\
139
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-loong64-npm-0.25.12-4fec31ffb2/node_modules/@esbuild/linux-loong64/",\
140
+ "packageDependencies": [\
141
+ ["@esbuild/linux-loong64", "npm:0.25.12"]\
142
+ ],\
143
+ "linkType": "HARD"\
144
+ }]\
145
+ ]],\
146
+ ["@esbuild/linux-mips64el", [\
147
+ ["npm:0.25.12", {\
148
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-mips64el-npm-0.25.12-827ebfd4ef/node_modules/@esbuild/linux-mips64el/",\
149
+ "packageDependencies": [\
150
+ ["@esbuild/linux-mips64el", "npm:0.25.12"]\
151
+ ],\
152
+ "linkType": "HARD"\
153
+ }]\
154
+ ]],\
155
+ ["@esbuild/linux-ppc64", [\
156
+ ["npm:0.25.12", {\
157
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-ppc64-npm-0.25.12-02e9c28638/node_modules/@esbuild/linux-ppc64/",\
158
+ "packageDependencies": [\
159
+ ["@esbuild/linux-ppc64", "npm:0.25.12"]\
160
+ ],\
161
+ "linkType": "HARD"\
162
+ }]\
163
+ ]],\
164
+ ["@esbuild/linux-riscv64", [\
165
+ ["npm:0.25.12", {\
166
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-riscv64-npm-0.25.12-3c5f314835/node_modules/@esbuild/linux-riscv64/",\
167
+ "packageDependencies": [\
168
+ ["@esbuild/linux-riscv64", "npm:0.25.12"]\
169
+ ],\
170
+ "linkType": "HARD"\
171
+ }]\
172
+ ]],\
173
+ ["@esbuild/linux-s390x", [\
174
+ ["npm:0.25.12", {\
175
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-s390x-npm-0.25.12-2106b3ddcb/node_modules/@esbuild/linux-s390x/",\
176
+ "packageDependencies": [\
177
+ ["@esbuild/linux-s390x", "npm:0.25.12"]\
178
+ ],\
179
+ "linkType": "HARD"\
180
+ }]\
181
+ ]],\
182
+ ["@esbuild/linux-x64", [\
183
+ ["npm:0.25.12", {\
184
+ "packageLocation": "./.yarn/unplugged/@esbuild-linux-x64-npm-0.25.12-07c7c22cce/node_modules/@esbuild/linux-x64/",\
185
+ "packageDependencies": [\
186
+ ["@esbuild/linux-x64", "npm:0.25.12"]\
187
+ ],\
188
+ "linkType": "HARD"\
189
+ }]\
190
+ ]],\
191
+ ["@esbuild/netbsd-arm64", [\
192
+ ["npm:0.25.12", {\
193
+ "packageLocation": "./.yarn/unplugged/@esbuild-netbsd-arm64-npm-0.25.12-bd2cdd7715/node_modules/@esbuild/netbsd-arm64/",\
194
+ "packageDependencies": [\
195
+ ["@esbuild/netbsd-arm64", "npm:0.25.12"]\
196
+ ],\
197
+ "linkType": "HARD"\
198
+ }]\
199
+ ]],\
200
+ ["@esbuild/netbsd-x64", [\
201
+ ["npm:0.25.12", {\
202
+ "packageLocation": "./.yarn/unplugged/@esbuild-netbsd-x64-npm-0.25.12-1f5039ae72/node_modules/@esbuild/netbsd-x64/",\
203
+ "packageDependencies": [\
204
+ ["@esbuild/netbsd-x64", "npm:0.25.12"]\
205
+ ],\
206
+ "linkType": "HARD"\
207
+ }]\
208
+ ]],\
209
+ ["@esbuild/openbsd-arm64", [\
210
+ ["npm:0.25.12", {\
211
+ "packageLocation": "./.yarn/unplugged/@esbuild-openbsd-arm64-npm-0.25.12-33119801dd/node_modules/@esbuild/openbsd-arm64/",\
212
+ "packageDependencies": [\
213
+ ["@esbuild/openbsd-arm64", "npm:0.25.12"]\
214
+ ],\
215
+ "linkType": "HARD"\
216
+ }]\
217
+ ]],\
218
+ ["@esbuild/openbsd-x64", [\
219
+ ["npm:0.25.12", {\
220
+ "packageLocation": "./.yarn/unplugged/@esbuild-openbsd-x64-npm-0.25.12-e97e4dea2a/node_modules/@esbuild/openbsd-x64/",\
221
+ "packageDependencies": [\
222
+ ["@esbuild/openbsd-x64", "npm:0.25.12"]\
223
+ ],\
224
+ "linkType": "HARD"\
225
+ }]\
226
+ ]],\
227
+ ["@esbuild/openharmony-arm64", [\
228
+ ["npm:0.25.12", {\
229
+ "packageLocation": "./.yarn/unplugged/@esbuild-openharmony-arm64-npm-0.25.12-b6855e9fc4/node_modules/@esbuild/openharmony-arm64/",\
230
+ "packageDependencies": [\
231
+ ["@esbuild/openharmony-arm64", "npm:0.25.12"]\
232
+ ],\
233
+ "linkType": "HARD"\
234
+ }]\
235
+ ]],\
236
+ ["@esbuild/sunos-x64", [\
237
+ ["npm:0.25.12", {\
238
+ "packageLocation": "./.yarn/unplugged/@esbuild-sunos-x64-npm-0.25.12-21a61a61f1/node_modules/@esbuild/sunos-x64/",\
239
+ "packageDependencies": [\
240
+ ["@esbuild/sunos-x64", "npm:0.25.12"]\
241
+ ],\
242
+ "linkType": "HARD"\
243
+ }]\
244
+ ]],\
245
+ ["@esbuild/win32-arm64", [\
246
+ ["npm:0.25.12", {\
247
+ "packageLocation": "./.yarn/unplugged/@esbuild-win32-arm64-npm-0.25.12-daf31eb7a1/node_modules/@esbuild/win32-arm64/",\
248
+ "packageDependencies": [\
249
+ ["@esbuild/win32-arm64", "npm:0.25.12"]\
250
+ ],\
251
+ "linkType": "HARD"\
252
+ }]\
253
+ ]],\
254
+ ["@esbuild/win32-ia32", [\
255
+ ["npm:0.25.12", {\
256
+ "packageLocation": "./.yarn/unplugged/@esbuild-win32-ia32-npm-0.25.12-7915b5b56e/node_modules/@esbuild/win32-ia32/",\
257
+ "packageDependencies": [\
258
+ ["@esbuild/win32-ia32", "npm:0.25.12"]\
259
+ ],\
260
+ "linkType": "HARD"\
261
+ }]\
262
+ ]],\
263
+ ["@esbuild/win32-x64", [\
264
+ ["npm:0.25.12", {\
265
+ "packageLocation": "./.yarn/unplugged/@esbuild-win32-x64-npm-0.25.12-2425a2e173/node_modules/@esbuild/win32-x64/",\
266
+ "packageDependencies": [\
267
+ ["@esbuild/win32-x64", "npm:0.25.12"]\
268
+ ],\
269
+ "linkType": "HARD"\
270
+ }]\
271
+ ]],\
272
+ ["esbuild", [\
273
+ ["npm:0.25.12", {\
274
+ "packageLocation": "../../.yarn/berry/cache/esbuild-npm-0.25.12-352393c4bd-10c0.zip/node_modules/esbuild/",\
275
+ "packageDependencies": [\
276
+ ["@esbuild/aix-ppc64", "npm:0.25.12"],\
277
+ ["@esbuild/android-arm", "npm:0.25.12"],\
278
+ ["@esbuild/android-arm64", "npm:0.25.12"],\
279
+ ["@esbuild/android-x64", "npm:0.25.12"],\
280
+ ["@esbuild/darwin-arm64", "npm:0.25.12"],\
281
+ ["@esbuild/darwin-x64", "npm:0.25.12"],\
282
+ ["@esbuild/freebsd-arm64", "npm:0.25.12"],\
283
+ ["@esbuild/freebsd-x64", "npm:0.25.12"],\
284
+ ["@esbuild/linux-arm", "npm:0.25.12"],\
285
+ ["@esbuild/linux-arm64", "npm:0.25.12"],\
286
+ ["@esbuild/linux-ia32", "npm:0.25.12"],\
287
+ ["@esbuild/linux-loong64", "npm:0.25.12"],\
288
+ ["@esbuild/linux-mips64el", "npm:0.25.12"],\
289
+ ["@esbuild/linux-ppc64", "npm:0.25.12"],\
290
+ ["@esbuild/linux-riscv64", "npm:0.25.12"],\
291
+ ["@esbuild/linux-s390x", "npm:0.25.12"],\
292
+ ["@esbuild/linux-x64", "npm:0.25.12"],\
293
+ ["@esbuild/netbsd-arm64", "npm:0.25.12"],\
294
+ ["@esbuild/netbsd-x64", "npm:0.25.12"],\
295
+ ["@esbuild/openbsd-arm64", "npm:0.25.12"],\
296
+ ["@esbuild/openbsd-x64", "npm:0.25.12"],\
297
+ ["@esbuild/openharmony-arm64", "npm:0.25.12"],\
298
+ ["@esbuild/sunos-x64", "npm:0.25.12"],\
299
+ ["@esbuild/win32-arm64", "npm:0.25.12"],\
300
+ ["@esbuild/win32-ia32", "npm:0.25.12"],\
301
+ ["@esbuild/win32-x64", "npm:0.25.12"],\
302
+ ["esbuild", "npm:0.25.12"]\
303
+ ],\
304
+ "linkType": "HARD"\
305
+ }]\
306
+ ]],\
37
307
  ["grape-swagger-rails", [\
38
308
  ["workspace:.", {\
39
309
  "packageLocation": "./",\
40
310
  "packageDependencies": [\
311
+ ["esbuild", "npm:0.25.12"],\
41
312
  ["grape-swagger-rails", "workspace:."],\
42
313
  ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"]\
43
314
  ],\
@@ -46,7 +317,7 @@ const RAW_RUNTIME_STATE =
46
317
  ]],\
47
318
  ["typescript", [\
48
319
  ["patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5", {\
49
- "packageLocation": "../../../.yarn/berry/cache/typescript-patch-6fda4d02cf-10c0.zip/node_modules/typescript/",\
320
+ "packageLocation": "../../.yarn/berry/cache/typescript-patch-6fda4d02cf-10c0.zip/node_modules/typescript/",\
50
321
  "packageDependencies": [\
51
322
  ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"]\
52
323
  ],\
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * Your contribution here.
4
4
 
5
+ ### 1.0.1 (2026/05/17)
6
+
7
+ * [#155](https://github.com/ruby-grape/grape-swagger-rails/pull/155): Fix: autoload default spec and restyle version dropdown - [@moskvin](https://github.com/moskvin).
8
+ * [#154](https://github.com/ruby-grape/grape-swagger-rails/pull/154): Add minified and sourcemap assets for swagger ui integration - [@moskvin](https://github.com/moskvin).
9
+ * [#153](https://github.com/ruby-grape/grape-swagger-rails/pull/153): Fix same-session deep link navigation not expanding operations - [@moskvin](https://github.com/moskvin).
10
+ * [#156](https://github.com/ruby-grape/grape-swagger-rails/pull/156): Bump esbuild from 0.24.2 to 0.25.0 - [@moskvin](https://github.com/moskvin).
11
+ * [#157](https://github.com/ruby-grape/grape-swagger-rails/pull/157): Bump swagger ui version to 5.32.6 - [@moskvin](https://github.com/moskvin).
12
+
5
13
  ### 1.0.0 (2026/05/09)
6
14
 
7
15
  * [#138](https://github.com/ruby-grape/grape-swagger-rails/pull/138): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock).
data/CLAUDE.md CHANGED
@@ -14,7 +14,9 @@ bundle exec rake spec # Run all RSpec tests only
14
14
  bundle exec rake rubocop # Run RuboCop linting only
15
15
  bundle exec rspec spec/features/swagger_spec.rb # Run a single spec file
16
16
 
17
- yarn build:frontend # Compile TypeScriptapp/assets/javascripts/grape_swagger_rails/index.js
17
+ yarn build:frontend # tsc index.js, then esbuild → index.min.js (+ .map)
18
+ yarn build:frontend:js # Just tsc (readable bundle)
19
+ yarn build:frontend:min # Just esbuild (minified bundle, consumes index.js)
18
20
  yarn typecheck # Type-check TypeScript without emitting
19
21
 
20
22
  bundle exec rake swagger_ui:dist:update # Update bundled Swagger UI assets
@@ -23,7 +25,7 @@ SWAGGER_UI_VERSION=v5.32.5 bundle exec rake swagger_ui:dist:update # Pin to a v
23
25
 
24
26
  Tests use Capybara + Selenium with Firefox. Firefox and geckodriver must be installed locally. On macOS, `xvfb` is not needed (unlike CI). Tests launch a real browser to validate UI behavior.
25
27
 
26
- **After editing TypeScript**, run `yarn build:frontend` before running specs — the specs exercise `app/assets/javascripts/grape_swagger_rails/index.js`, which is the compiled output. Never edit the compiled JS directly.
28
+ **After editing TypeScript**, run `yarn build:frontend` before running specs — the specs exercise `app/assets/javascripts/grape_swagger_rails/index.js`, which is the compiled output. Never edit the compiled JS directly. The build also emits `index.min.js` (+ sourcemap); the view picks the minified bundle in production (`Rails.env.production?`) via `grape_swagger_rails_runtime_asset` and the readable one everywhere else.
27
29
 
28
30
  ## Architecture
29
31
 
@@ -33,7 +35,7 @@ The gem has minimal moving parts:
33
35
  - **`lib/grape-swagger-rails/engine.rb`** — Rails Engine. Configures asset precompilation for both Sprockets and Propshaft pipelines.
34
36
  - **`app/controllers/grape_swagger_rails/application_controller.rb`** — Single `index` action. Runs `options.before_action_proc` in controller context for authorization.
35
37
  - **`app/views/grape_swagger_rails/application/index.html.haml`** — The entire UI. Serializes `GrapeSwaggerRails.options` as JSON into `data-swagger-options`, then JavaScript parses it to initialize SwaggerUIBundle. Handles theme toggling and auth injection via Swagger UI's `requestInterceptor`.
36
- - **`frontend/grape_swagger_rails/index.ts`** — TypeScript source for the browser runtime. Compiles (via `tsconfig.json`) to `app/assets/javascripts/grape_swagger_rails/index.js`. The TypeScript interface `SwaggerPageOptions` is the authoritative schema for options consumed by JS.
38
+ - **`frontend/grape_swagger_rails/index.ts`** — TypeScript source for the browser runtime. `tsc` compiles it to `app/assets/javascripts/grape_swagger_rails/index.js` (readable, ES5); `esbuild` then minifies that into `index.min.js` (+ `.map`). Both files are checked in so they ship with the gem. The TypeScript interface `SwaggerPageOptions` is the authoritative schema for options consumed by JS.
37
39
  - **`config/routes.rb`** — Single root route → `ApplicationController#index`.
38
40
  - **`lib/tasks/swagger_ui.rake`** — Rake task that clones `swagger-api/swagger-ui` and copies dist files into `app/assets/`.
39
41
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ Swagger UI as Rails Engine for grape-swagger gem.
17
17
  - [API Token Authentication](#api-token-authentication)
18
18
  - [Swagger UI Authorization](#swagger-ui-authorization)
19
19
  - [Integration with DoorKeeper](#integration-with-doorkeeper)
20
- - [Hiding the API or Authorization text boxes](#hiding-the-api-or-authorization-text-boxes)
20
+ - [Show or Hide Swagger UI Elements](#show-or-hide-swagger-ui-elements)
21
21
  - [Updating Swagger UI from Dist](#updating-swagger-ui-from-dist)
22
22
  - [Contributors](#contributors)
23
23
  - [AI Agents](#ai-agents)
@@ -258,21 +258,27 @@ In your User model (user.rb) add:
258
258
  has_one :token, -> { order 'created_at DESC' }, class_name: Doorkeeper::AccessToken, foreign_key: :resource_owner_id
259
259
  ```
260
260
 
261
- ### Hiding the API or Authorization text boxes
261
+ ### Show or Hide Swagger UI Elements
262
262
 
263
- If you know in advance that you would like to prevent changing the Swagger API URL, you can hide it using the following:
263
+ Use `display` to control visibility of the built-in Swagger UI header elements:
264
264
 
265
265
  ```ruby
266
- GrapeSwaggerRails.options.hide_url_input = true
266
+ GrapeSwaggerRails.options.display = {
267
+ api_key_input: false,
268
+ info_url: false,
269
+ doc_version: false,
270
+ version_stamp: false
271
+ }
267
272
  ```
268
273
 
269
- Similarly, you can hide the Authentication input box by adding this:
274
+ Supported keys:
270
275
 
271
- ```ruby
272
- GrapeSwaggerRails.options.hide_api_key_input = true
273
- ```
276
+ - `api_key_input`: show or hide the authentication input box
277
+ - `info_url`: show or hide the API document URL link
278
+ - `doc_version`: show or hide the API document version label
279
+ - `version_stamp`: show or hide the `OAS 2.0` version stamp
274
280
 
275
- By default, these options are false.
281
+ By default, all of these options are `true`.
276
282
 
277
283
  ### Updating Swagger UI from Dist
278
284
 
@@ -1,5 +1,13 @@
1
1
  "use strict";
2
- function initializeSwaggerPage() {
2
+ var safeDecodeURIComponent = function (value) {
3
+ try {
4
+ return decodeURIComponent(value);
5
+ }
6
+ catch (_a) {
7
+ return value;
8
+ }
9
+ };
10
+ var initializeSwaggerPage = function () {
3
11
  var optionsElement = document.documentElement.dataset.swaggerOptions;
4
12
  if (!optionsElement ||
5
13
  typeof SwaggerUIBundle === "undefined" ||
@@ -12,10 +20,10 @@ function initializeSwaggerPage() {
12
20
  var specSelectorWrapper = document.getElementById("spec-selector-wrapper");
13
21
  var themeToggle = document.getElementById("theme-toggle");
14
22
  var root = document.documentElement;
15
- function getTheme() {
23
+ var getTheme = function () {
16
24
  return options.theme === "dark" ? "dark" : "light";
17
- }
18
- function applyTheme(theme) {
25
+ };
26
+ var applyTheme = function (theme) {
19
27
  root.dataset.theme = theme;
20
28
  root.classList.toggle("dark-mode", theme === "dark");
21
29
  if (!themeToggle) {
@@ -23,8 +31,8 @@ function initializeSwaggerPage() {
23
31
  }
24
32
  themeToggle.textContent = theme === "dark" ? "Light Mode" : "Dark Mode";
25
33
  themeToggle.setAttribute("aria-pressed", String(theme === "dark"));
26
- }
27
- function getApiKeyValue() {
34
+ };
35
+ var getApiKeyValue = function () {
28
36
  if (!authInput) {
29
37
  return "";
30
38
  }
@@ -42,22 +50,22 @@ function initializeSwaggerPage() {
42
50
  return "Token token=\"".concat(key, "\"");
43
51
  }
44
52
  return key;
45
- }
46
- function ensureRequestHeaders(request) {
53
+ };
54
+ var ensureRequestHeaders = function (request) {
47
55
  if (!request.headers) {
48
56
  request.headers = {};
49
57
  }
50
58
  return request.headers;
51
- }
52
- function setRequestHeader(request, key, value) {
59
+ };
60
+ var setRequestHeader = function (request, key, value) {
53
61
  var headers = ensureRequestHeaders(request);
54
62
  if (headers instanceof Headers) {
55
63
  headers.set(key, value);
56
64
  return;
57
65
  }
58
66
  headers[key] = value;
59
- }
60
- function absoluteSpecUrl(url) {
67
+ };
68
+ var absoluteSpecUrl = function (url) {
61
69
  if (!url) {
62
70
  return "";
63
71
  }
@@ -65,8 +73,8 @@ function initializeSwaggerPage() {
65
73
  return url;
66
74
  }
67
75
  return options.app_url + url;
68
- }
69
- function normalizeSwaggerUrls() {
76
+ };
77
+ var normalizeSwaggerUrls = function () {
70
78
  if (!Array.isArray(options.urls)) {
71
79
  return [];
72
80
  }
@@ -82,8 +90,8 @@ function initializeSwaggerPage() {
82
90
  };
83
91
  })
84
92
  .filter(function (entry) { return Boolean(entry.url); });
85
- }
86
- function selectedSwaggerUrl(urls) {
93
+ };
94
+ var selectedSwaggerUrl = function (urls) {
87
95
  if (!urls.length) {
88
96
  return null;
89
97
  }
@@ -101,8 +109,8 @@ function initializeSwaggerPage() {
101
109
  }
102
110
  }
103
111
  return urls[0];
104
- }
105
- function setupSpecSelector(urls, selectedUrl) {
112
+ };
113
+ var setupSpecSelector = function (urls, selectedUrl) {
106
114
  if (!specSelector || !specSelectorWrapper || urls.length < 2) {
107
115
  return;
108
116
  }
@@ -116,29 +124,29 @@ function initializeSwaggerPage() {
116
124
  specSelector.appendChild(option);
117
125
  });
118
126
  specSelectorWrapper.hidden = false;
119
- }
120
- function hideInfoUrlPlugin() {
127
+ };
128
+ var hideInfoUrlPlugin = function () {
121
129
  return {
122
130
  wrapComponents: {
123
131
  InfoUrl: function () { return function () { return null; }; },
124
132
  },
125
133
  };
126
- }
127
- function hideDocVersionPlugin() {
134
+ };
135
+ var hideDocVersionPlugin = function () {
128
136
  return {
129
137
  wrapComponents: {
130
138
  VersionStamp: function () { return function () { return null; }; },
131
139
  },
132
140
  };
133
- }
134
- function hideVersionStampPlugin() {
141
+ };
142
+ var hideVersionStampPlugin = function () {
135
143
  return {
136
144
  wrapComponents: {
137
145
  OpenAPIVersion: function () { return function () { return null; }; },
138
146
  },
139
147
  };
140
- }
141
- function buildPlugins() {
148
+ };
149
+ var buildPlugins = function () {
142
150
  var configuredPlugins = options.swagger_ui_config && options.swagger_ui_config.plugins;
143
151
  var plugins = Array.isArray(configuredPlugins) ? configuredPlugins.slice() : [];
144
152
  var displayDefaults = { api_key_input: true, info_url: true, doc_version: true, version_stamp: true };
@@ -153,7 +161,7 @@ function initializeSwaggerPage() {
153
161
  plugins.push(hideVersionStampPlugin);
154
162
  }
155
163
  return plugins;
156
- }
164
+ };
157
165
  applyTheme(getTheme());
158
166
  if (themeToggle) {
159
167
  themeToggle.addEventListener("click", function () {
@@ -204,6 +212,10 @@ function initializeSwaggerPage() {
204
212
  bundleConfig.url = absoluteSpecUrl(options.url);
205
213
  }
206
214
  window.ui = SwaggerUIBundle(bundleConfig);
215
+ if (selectedUrl) {
216
+ window.ui.specActions.updateUrl(selectedUrl.url);
217
+ window.ui.specActions.download(selectedUrl.url);
218
+ }
207
219
  setupSpecSelector(swaggerUrls, selectedUrl);
208
220
  if (specSelector && swaggerUrls.length > 1) {
209
221
  specSelector.addEventListener("change", function (event) {
@@ -213,7 +225,48 @@ function initializeSwaggerPage() {
213
225
  window.ui.specActions.download(url);
214
226
  });
215
227
  }
216
- }
228
+ // Listen for hash changes so that navigating to a deep-link URL in the same
229
+ // tab (e.g. pasting a copied operation URL into the address bar) expands the
230
+ // target operation without requiring a full page refresh.
231
+ //
232
+ // NOTE: We intentionally do NOT use `layoutActions.parseDeepLinkHash()` here.
233
+ // That method is Swagger UI's built-in deep linking plugin action, designed to
234
+ // run during initial spec load (inside the `onComplete` callback). When called
235
+ // after spec rendering is complete, it fails to expand operations — likely
236
+ // because it depends on internal state or lifecycle context that no longer applies.
237
+ //
238
+ // Instead, we directly call `layoutActions.show()` which reliably toggles the
239
+ // visibility of tags/operations, then scroll into view manually.
240
+ window.addEventListener("hashchange", function () {
241
+ var hash = window.location.hash;
242
+ if (!hash || hash === "#") {
243
+ return;
244
+ }
245
+ // Hash format used by Swagger UI deep linking: #/tag/operationId
246
+ var parts = hash.replace(/^#\/?/, "").split("/").filter(Boolean);
247
+ if (parts.length === 0) {
248
+ return;
249
+ }
250
+ var tag = safeDecodeURIComponent(parts[0]);
251
+ var operationId = parts.length > 1 ? safeDecodeURIComponent(parts[1]) : null;
252
+ window.ui.layoutActions.show(["operations-tag", tag], true);
253
+ if (operationId) {
254
+ window.ui.layoutActions.show(["operations", tag, operationId], true);
255
+ }
256
+ // Scroll to the expanded element. Swagger UI uses id="operations-{tag}-{operationId}"
257
+ // for operations and id="operations-tag-{tag}" for tag sections. Use a small delay
258
+ // to allow the DOM to update after the layout action.
259
+ var targetId = operationId
260
+ ? "operations-" + tag + "-" + operationId
261
+ : "operations-tag-" + tag;
262
+ requestAnimationFrame(function () {
263
+ var element = document.getElementById(targetId);
264
+ if (element) {
265
+ element.scrollIntoView({ behavior: "smooth", block: "start" });
266
+ }
267
+ });
268
+ });
269
+ };
217
270
  if (document.readyState === "loading") {
218
271
  document.addEventListener("DOMContentLoaded", initializeSwaggerPage);
219
272
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var safeDecodeURIComponent=function(o){try{return decodeURIComponent(o)}catch{return o}},initializeSwaggerPage=function(){var o=document.documentElement.dataset.swaggerOptions;if(!(!o||typeof SwaggerUIBundle>"u"||typeof SwaggerUIStandalonePreset>"u")){var r=JSON.parse(o),p=document.getElementById("input_apiKey"),l=document.getElementById("spec-selector"),m=document.getElementById("spec-selector-wrapper"),u=document.getElementById("theme-toggle"),g=document.documentElement,_=function(){return r.theme==="dark"?"dark":"light"},v=function(e){g.dataset.theme=e,g.classList.toggle("dark-mode",e==="dark"),u&&(u.textContent=e==="dark"?"Light Mode":"Dark Mode",u.setAttribute("aria-pressed",String(e==="dark")))},y=function(){if(!p)return"";var e=p.value?p.value.trim():"";return e?r.api_auth==="basic"?"Basic "+btoa(e):r.api_auth==="bearer"?"Bearer "+e:r.api_auth==="token"?'Token token="'.concat(e,'"'):e:""},I=function(e){return e.headers||(e.headers={}),e.headers},h=function(e,n,a){var t=I(e);if(t instanceof Headers){t.set(n,a);return}t[n]=a},d=function(e){return e?/^https?:\/\//.test(e)?e:r.app_url+e:""},S=function(){return Array.isArray(r.urls)?r.urls.map(function(e,n){return typeof e=="string"?{name:e,url:d(e),default:!1}:{name:e.name||e.url||"Spec "+(n+1),url:d(e.url),default:!!e.default}}).filter(function(e){return!!e.url}):[]},k=function(e){if(!e.length)return null;for(var n=0;n<e.length;n+=1)if(e[n].default)return e[n];if(r.url){for(var a=d(r.url),t=0;t<e.length;t+=1)if(e[t].url===a)return e[t]}return e[0]},U=function(e,n){!l||!m||e.length<2||(e.forEach(function(a){var t=document.createElement("option");t.value=a.url,t.textContent=a.name,n&&a.url===n.url&&(t.selected=!0),l.appendChild(t)}),m.hidden=!1)},E=function(){return{wrapComponents:{InfoUrl:function(){return function(){return null}}}}},b=function(){return{wrapComponents:{VersionStamp:function(){return function(){return null}}}}},A=function(){return{wrapComponents:{OpenAPIVersion:function(){return function(){return null}}}}},B=function(){var e=r.swagger_ui_config&&r.swagger_ui_config.plugins,n=Array.isArray(e)?e.slice():[],a={api_key_input:!0,info_url:!0,doc_version:!0,version_stamp:!0},t=Object.assign({},a,r.display||{});return t.info_url||n.push(E),t.doc_version||n.push(b),t.version_stamp||n.push(A),n};v(_()),u&&u.addEventListener("click",function(){r.theme=g.dataset.theme==="dark"?"light":"dark",v(r.theme)});var s=S(),i=k(s),c=Object.assign({},r.swagger_ui_config||{},{dom_id:"#swagger-ui-container",deepLinking:!0,docExpansion:r.doc_expansion,supportedSubmitMethods:r.supported_submit_methods||[],validatorUrl:r.validator_url,layout:"BaseLayout",presets:[SwaggerUIBundle.presets.apis,SwaggerUIStandalonePreset],plugins:B(),requestInterceptor:function(e){var n=r.headers||{};Object.keys(n).forEach(function(f){h(e,f,n[f])});var a=y();if(!a)return e;if(r.api_key_type==="query"){var t=e.url.indexOf("?")===-1?"?":"&";return e.url+=t+encodeURIComponent(r.api_key_name)+"="+encodeURIComponent(a),e}return h(e,r.api_key_name,a),e}});s.length?(c.urls=s,i&&(c["urls.primaryName"]=i.name)):c.url=d(r.url),window.ui=SwaggerUIBundle(c),i&&(window.ui.specActions.updateUrl(i.url),window.ui.specActions.download(i.url)),U(s,i),l&&s.length>1&&l.addEventListener("change",function(e){var n=e.target,a=n.value;window.ui.specActions.updateUrl(a),window.ui.specActions.download(a)}),window.addEventListener("hashchange",function(){var e=window.location.hash;if(!(!e||e==="#")){var n=e.replace(/^#\/?/,"").split("/").filter(Boolean);if(n.length!==0){var a=safeDecodeURIComponent(n[0]),t=n.length>1?safeDecodeURIComponent(n[1]):null;window.ui.layoutActions.show(["operations-tag",a],!0),t&&window.ui.layoutActions.show(["operations",a,t],!0);var f=t?"operations-"+a+"-"+t:"operations-tag-"+a;requestAnimationFrame(function(){var w=document.getElementById(f);w&&w.scrollIntoView({behavior:"smooth",block:"start"})})}}})}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initializeSwaggerPage):initializeSwaggerPage();
2
+ //# sourceMappingURL=index.min.js.map