oas_rails 0.10.1 → 0.11.0

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: e7aba5fe8b9983dd63d1ff69467c419f26ac1c0733737da6994d65542ff00a5c
4
- data.tar.gz: 7df7cc51ffcdb2690c42a9aaa6eef1d13ede77a96f6ae5b97891be16cc76dae1
3
+ metadata.gz: 0c02c7a454cec38660f5d327e61f35c88e3d7ab22b4fc5c18adbed3707c656d7
4
+ data.tar.gz: 8fb227b665f88c0c6299f1a1bbd9d4c681f1438c13fa93e6f552cd96b1ef7a00
5
5
  SHA512:
6
- metadata.gz: f01774e088f4edd899ec6fe02373f29ddf609c8102f4759f372d32ffa36798fa3f35ee3c2f6137d21063b51d22c8df94de9f1fbaa12c4ad198ff2150a92df16b
7
- data.tar.gz: 15c21a08bb93729fc3c1f129a2b4008f44132cf01e9b10a58e72a8c867fc985bd3f3e3a4f32cab03ff621ceaa41e674b6d927047351b254f92a51111ad15a69c
6
+ metadata.gz: 2d30c6f893f17476716208e57311b2c290f99208431781085de77d97d9c6c2d5601df5c29e53155d485a3e2d1268383ca6151dd97ae629461db2b8c369df9cdc
7
+ data.tar.gz: 6b7edd8df46e2ea3b8c20fdbc41ceed453f560a0c619fed3138ae49a5366625e34b36fd0ee6c5d1aff549602c00ae2e4e1b880b58ae1e6f62ffed4c1578e4c6d
data/README.md CHANGED
@@ -37,452 +37,9 @@ After experiencing the interactive documentation in Python's fast-api framework,
37
37
 
38
38
  The goal is to minimize the effort required to create comprehensive documentation. By following REST principles in Rails, we believe this is achievable. You can enhance the documentation using [Yard](https://yardoc.org/) tags.
39
39
 
40
- ## 📋 Table of Contents
40
+ ## Documentation
41
41
 
42
- - [Installation](#installation)
43
- - [Configuration](#configuration)
44
- - [Basic Information about the API](#basic-information-about-the-api)
45
- - [Servers Information](#servers-information)
46
- - [Tag Information](#tag-information)
47
- - [Optional Settings](#optional-settings)
48
- - [Authentication Settings](#authentication-settings)
49
- - [Default Responses (Errors)](#default-responses)
50
- - [Usage](#usage)
51
- - [Documenting Your Endpoints](#documenting-your-endpoints)
52
- - [Example](#example-of-documented-endpoints)
53
- - [Securing the OasRails Engine](#securing-the-oasrails-engine)
54
- - [Customizing the View](#customizing-the-view)
55
- - [Contributing](#contributing)
56
- - [Roadmap and Ideas for Improvement](#roadmap-and-ideas-for-improvement)
57
- - [License](#license)
58
-
59
- ## Installation
60
-
61
- 1. Add this line to your Rails application's Gemfile:
62
-
63
- ```ruby
64
- gem "oas_rails"`
65
- ```
66
-
67
- 2. Execute:
68
-
69
- ```bash
70
- bundle
71
- ```
72
-
73
- 3. Mount the engine in your config/routes.rb file
74
-
75
- ```ruby
76
- mount OasRails::Engine => '/docs'
77
- ```
78
-
79
- You'll now have **basic documentation** based on your routes and automatically gathered information at `localhost:3000/docs`. To enhance it, create an initializer file and add [Yard](https://yardoc.org/) tags to your controller methods.
80
-
81
- ## ⚙️ Configuration
82
-
83
- To configure OasRails, **you MUST create an initializer file** including all your settings. The first step is to create your initializer file, which you can easily do with:
84
-
85
- ```bash
86
- rails generate oas_rails:config
87
- ```
88
-
89
- Then fill it with your data. Below are the available configuration options:
90
-
91
- ### Basic Information about the API
92
-
93
- - `config.info.title`: The title of your API documentation.
94
- - `config.info.summary`: A brief summary of your API.
95
- - `config.info.description`: A detailed description of your API. This can include markdown formatting and will be displayed prominently in your documentation.
96
- - `config.info.contact.name`: The name of the contact person or organization.
97
- - `config.info.contact.email`: The contact email address.
98
- - `config.info.contact.url`: The URL for more information or support.
99
-
100
- ### Servers Information
101
-
102
- - `config.servers`: An array of server objects, each containing `url` and `description` keys. For more details, refer to the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html#server-object).
103
-
104
- ### Tag Information
105
-
106
- - `config.tags`: An array of tag objects, each containing `name` and `description` keys. For more details, refer to the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html#tag-object).
107
-
108
- ### Optional Settings
109
-
110
- - `config.default_tags_from`: Determines the source of default tags for operations. Can be set to `:namespace` or `:controller`.
111
- - `config.autodiscover_request_body`: Automatically detects request bodies for create/update methods. Default is `true`.
112
- - `config.autodiscover_responses`: Automatically detects responses from controller renders. Default is `true`.
113
- - `config.api_path`: Sets the API path if your API is under a different namespace.
114
- - `config.ignored_actions`: Sets an array with the controller or controller#action. No necessary to add api_path before.
115
- - `config.http_verbs`: Defaults to `[:get, :post, :put, :patch, :delete]`
116
- - `config.use_model_names`: Use model names when possible, defaults to `false`
117
-
118
- ### Authentication Settings
119
-
120
- - `config.authenticate_all_routes_by_default`: Determines whether to authenticate all routes by default. Default is `true`.
121
- - `config.security_schema`: The default security schema used for authentication. Choose a predefined security schema from `[:api_key_cookie, :api_key_header, :api_key_query, :basic, :bearer, :bearer_jwt, :mutual_tls]`.
122
- - `config.security_schemas`: Custom security schemas. Follow the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html#security-scheme-object) for defining these schemas.
123
-
124
- ### Default Errors
125
-
126
- - `config.set_default_responses`: Determines whether to add default errors responses to endpoint. Default is `true`.
127
-
128
- - `config.possible_default_responses`: Array with possible default errors.(Some will be added depending on the endpoint, example: not_found only works with show/update/delete). Default: [:not_found, :unauthorized, :forbidden]. It should be HTTP status code symbols from the list: `[:not_found, :unauthorized, :forbidden, :internal_server_error, :unprocessable_entity]`
129
-
130
- - `config.response_body_of_default`: body for use in default responses. It must be a String hash like the used in request body tags. Default: "{ message: String }"
131
-
132
- ## 📓 Usage
133
-
134
- In addition to the information provided in the initializer file and the data that can be extracted from the routes and methods automatically, it is essential to document your API in the following way. The documentation is created **with the help of YARD**, so the methods are documented with **comment tags**.
135
-
136
- ### Documenting Your Endpoints
137
-
138
- Almost every tag description in an OAS file supports **markdown formatting** (e.g., bold, italics, lists, links) for better readability in the generated documentation. Additionally, **multi-line descriptions** are supported. When using multi-line descriptions, ensure the content is indented at least one space more than the tag itself to maintain proper formatting.
139
-
140
- For example:
141
-
142
- ```ruby
143
- # @request_body_example Simple User [Hash]
144
- # {
145
- # user: {
146
- # name: "Oas",
147
- # email: "oas@test.com",
148
- # password: "Test12345"
149
- # }
150
- # }
151
- ```
152
-
153
- <details>
154
- <summary style="font-weight: bold; font-size: 1.2em;">@summary</summary>
155
-
156
- **Structure**: `@summary text`
157
-
158
- Used to add a summary to the endpoint. It replaces the default summary/title of the endpoint.
159
-
160
- **Example**:
161
-
162
- `# @summary This endpoint creates a User`
163
-
164
- ```
165
- # @summary This endpoint
166
- # creates a User
167
- ```
168
-
169
- </details>
170
-
171
- <details>
172
- <summary style="font-weight: bold; font-size: 1.2em;">@parameter</summary>
173
-
174
- **Structure**: `@parameter name(position) [type] text`
175
-
176
- Represents a parameter for the endpoint. The position can be: `header`, `path`, `cookie`, or `query`. The type should be a valid Ruby class: `String`, `Integer`, `Array<String>`, etc. Add a `!` before the class to indicate a required parameter.
177
-
178
- **Examples**:
179
- `# @parameter page(query) [Integer] The page number.`
180
- `# @parameter slug(path) [!String] Slug of the Project.`
181
-
182
- </details>
183
-
184
- <details>
185
- <summary style="font-weight: bold; font-size: 1.2em;">@request_body</summary>
186
-
187
- **Structure**: `@request_body text [type<structure>]`
188
-
189
- Documents the request body needed by the endpoint. The structure is optional if you provide a valid Active Record class. Use `!` to indicate a required request body.
190
-
191
- **One line example**:
192
-
193
- `# @request_body The user to be created [!User]`
194
-
195
- `# @request_body The user to be created [User]`
196
-
197
- **Multi-line example**:
198
-
199
- ```ruby
200
- # @request_body User to be created
201
- # [
202
- # !Hash{
203
- # user: Hash{
204
- # name: String,
205
- # email: String,
206
- # age: Integer,
207
- # cars: Array<
208
- # Hash{
209
- # identifier: String
210
- # }
211
- # >
212
- # }
213
- # }
214
- # ]
215
- ```
216
-
217
- </details>
218
-
219
- <details>
220
- <summary style="font-weight: bold; font-size: 1.2em;">@request_body_example</summary>
221
-
222
- **Structure**: `@request_body_example text [type] structure`
223
-
224
- Adds examples to the provided request body.
225
-
226
- **One line example**:
227
-
228
- `# @request_body_example A complete User. [Hash] {user: {name: 'Luis', age: 30, password: 'MyWeakPassword123'}}`
229
-
230
- **Multi-line example**:
231
-
232
- ```ruby
233
- # @request_body_example basic user [Hash]
234
- # {
235
- # user: {
236
- # name: "Oas",
237
- # email: "oas@test.com",
238
- # password: "Test12345"
239
- # }
240
- # }
241
- ```
242
-
243
- </details>
244
-
245
- <details>
246
- <summary style="font-weight: bold; font-size: 1.2em;">@response</summary>
247
-
248
- **Structure**: `@response text(code) [type<structure>]`
249
-
250
- Documents the responses of the endpoint and overrides the default responses found by the engine.
251
-
252
- **One line example**:
253
-
254
- `# @response User not found by the provided Id(404) [Hash{success: Boolean, message: String}]`
255
-
256
- `# @response Validation errors(422) [Hash{success: Boolean, errors: Array<Hash{field: String, type: String, detail: Array<String>}>}]`
257
-
258
- **Multi-line example**:
259
-
260
- ```ruby
261
- # @response A test response from an Issue(405)
262
- # [
263
- # Hash{
264
- # message: String,
265
- # data: Hash{
266
- # availabilities: Array<String>,
267
- # dates: Array<Date>
268
- # }
269
- # }
270
- # ]
271
- ```
272
-
273
- </details>
274
-
275
- <details>
276
- <summary style="font-weight: bold; font-size: 1.2em;">@response_example</summary>
277
-
278
- **Structure**: `@response_example text(code) [String Hash]`
279
-
280
- Documents response examples of the endpoint associated to a response code.
281
-
282
- **One line example**:
283
-
284
- `# @response_example Invalida Email(422) [{success: "false", errors: [{field: "email", type: "email", detail: ["Invalid email"]}] }]`
285
-
286
- `# @response_example Id not exists (404) [{success: "false", message: "Nothing found with the provided ID." }]`
287
-
288
- **Multi-line example**:
289
-
290
- ```ruby
291
- # @response_example Another 405 Error (405) [Hash]
292
- # {
293
- # message: "another",
294
- # data: {
295
- # availabilities: [
296
- # "three"
297
- # ],
298
- # dates: []
299
- # }
300
- # }
301
- ```
302
-
303
- </details>
304
-
305
- <details>
306
- <summary style="font-weight: bold; font-size: 1.2em;">@tag</summary>
307
-
308
- **Structure**: `@tag text`
309
-
310
- Tags your endpoints. You can complete the tag documentation in the initializer file by defining these tags beforehand. It's not necessary for the tag to exist in your initializer file before use.
311
-
312
- **Example**:
313
- `# @tag Users`
314
-
315
- </details>
316
-
317
- <details>
318
- <summary style="font-weight: bold; font-size: 1.2em;">@no_auth</summary>
319
-
320
- **Structure**: `@no_auth`
321
-
322
- This tag will remove any security requirement from the endpoint. Useful when most of your endpoints require authentication and only a few do not.(Ex: Login, Registration...)
323
-
324
- **Example**:
325
- `# @no_auth`
326
-
327
- </details>
328
-
329
- <details>
330
- <summary style="font-weight: bold; font-size: 1.2em;">@auth</summary>
331
-
332
- **Structure**: `@auth [types]`
333
-
334
- This tag will set which security mechanisms can be used for the endpoint. The security mechanisms MUST be defined previously in the initializer file.
335
-
336
- **Example**:
337
- `# @auth [bearer, basic]`
338
-
339
- </details>
340
-
341
- You can use these tags in your controller methods to enhance the automatically generated documentation. Remember to use markdown formatting in your descriptions for better readability in the generated OAS document.
342
-
343
- ### Example of documented endpoints
344
-
345
- ```ruby
346
- class UsersController < ApplicationController
347
- before_action :set_user, only: %i[show update destroy]
348
-
349
- # @summary Returns a list of Users.
350
- #
351
- # @parameter offset(query) [Integer] Used for pagination of response data (default: 25 items per response). Specifies the offset of the next block of data to receive.
352
- # @parameter status(query) [Array<String>] Filter by status. (e.g. status[]=inactive&status[]=deleted).
353
- # @parameter X-front(header) [String] Header for identify the front.
354
- def index
355
- @users = User.all
356
- end
357
-
358
- # @summary Get a user by id.
359
- # @auth [bearer]
360
- #
361
- # This method show a User by ID. The id must exist of other way it will be returning a **`404`**.
362
- #
363
- # @parameter id(path) [Integer] Used for identify the user.
364
- # @response Requested User(200) [Hash] {user: {name: String, email: String, created_at: DateTime }}
365
- # @response User not found by the provided Id(404) [Hash] {success: Boolean, message: String}
366
- # @response You don't have the right permission for access to this resource(403) [Hash] {success: Boolean, message: String}
367
- def show
368
- render json: @user
369
- end
370
-
371
- # @summary Create a User
372
- # @no_auth
373
- #
374
- # @request_body The user to be created. At least include an `email`. [!User]
375
- # @request_body_example basic user [Hash] {user: {name: "Luis", email: "luis@gmail.ocom"}}
376
- def create
377
- @user = User.new(user_params)
378
-
379
- if @user.save
380
- render json: @user, status: :created
381
- else
382
- render json: { success: false, errors: @user.errors }, status: :unprocessable_entity
383
- end
384
- end
385
-
386
- # A `user` can be updated with this method
387
- # - There is no option
388
- # - It must work
389
- # @tags users, update
390
- # @request_body User to be created [!Hash{user: { name: String, email: !String, age: Integer, available_dates: Array<Date>}}]
391
- # @request_body_example Update user [Hash] {user: {name: "Luis", email: "luis@gmail.com"}}
392
- # @request_body_example Complete User [Hash] {user: {name: "Luis", email: "luis@gmail.com", age: 21}}
393
- def update
394
- if @user.update(user_params)
395
- render json: @user
396
- else
397
- render json: @user.errors, status: :unprocessable_entity
398
- end
399
- end
400
-
401
- # @summary Delete a User
402
- # Delete a user and his associated data.
403
- def destroy
404
- @user.destroy!
405
- redirect_to users_url, notice: 'User was successfully destroyed.', status: :see_other
406
- end
407
-
408
- private
409
-
410
- # Use callbacks to share common setup or constraints between actions.
411
- def set_user
412
- @user = User.find(params[:id])
413
- end
414
-
415
- # Only allow a list of trusted parameters through.
416
- def user_params
417
- params.require(:user).permit(:name, :email)
418
- end
419
- end
420
- ```
421
-
422
- ## 🔒Securing the OasRails Engine
423
-
424
- To secure the OasRails engine, which exposes an endpoint for showing the OAS definition, you can configure authentication to ensure that only authorized users have access. Here are a few methods to achieve this:
425
-
426
- ### 1. Using Basic Authentication
427
-
428
- Use basic authentication to protect the OasRails endpoint. You can set this up in an initializer:
429
-
430
- ```ruby
431
- # config/initializers/oas_rails.rb
432
- OasRails::Engine.middleware.use(Rack::Auth::Basic) do |username, password|
433
- ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.oas_rails_username, username) &
434
- ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.oas_rails_password, password)
435
- end
436
- ```
437
-
438
- ### 2. Using Devise's `authenticate` Helper
439
-
440
- You can use Devise's `authenticate` helper to restrict access to the OasRails endpoint. For example, you can allow only admin users to access the endpoint:
441
-
442
- ```ruby
443
- # config/routes.rb
444
- # ...
445
- authenticate :user, ->(user) { user.admin? } do
446
- mount OasRails::Engine, at: '/docs'
447
- end
448
- ```
449
-
450
- ### 3. Custom Authentication
451
-
452
- To support custom authentication, you can extend the OasRails' ApplicationController using a hook. This allows you to add custom before actions to check for specific user permissions:
453
-
454
- ```ruby
455
- # config/initializers/oas_rails.rb
456
-
457
- ActiveSupport.on_load(:oas_rails_application_controller) do
458
- # context here is OasRails::ApplicationController
459
-
460
- before_action do
461
- raise ActionController::RoutingError.new('Not Found') unless current_user&.admin?
462
- end
463
-
464
- def current_user
465
- # Load the current user
466
- User.find(session[:user_id]) # Adjust according to your authentication logic
467
- end
468
- end
469
- ```
470
-
471
- ## ⛏️ Customizing the View
472
-
473
- The OasRails engine provides an easy way to display your OpenAPI Specification (OAS) within your Rails application. By default, it includes an `index` view in the `OasRailsController` that displays [RapiDoc](https://rapidocweb.com/) through a CDN with default configurations. You can easily override this view to replace RapiDoc entirely or configure it differently.
474
-
475
- #### Overriding the `index` View
476
-
477
- To override the `index` view provided by the OasRails engine, follow these steps:
478
-
479
- 1. **Create the Override View File**: In your host application, create a new file at the path `app/views/oas_rails/oas_rails/index.html.erb`. If the directories do not exist, you will need to create them.
480
-
481
- 2. **Customize the View**: Open the newly created `index.html.erb` file and add your custom HTML and ERB code to display the OAS as desired. You can refer to the source code of this project for guidance.
482
-
483
- #### Using the Custom View
484
-
485
- Once the custom view file is in place, Rails will automatically use it instead of the view provided by the OasRails engine. This allows you to fully customize the presentation of the OAS without modifying the engine's code.
42
+ For see how to install, configure and use OasRails please refere to the [OasRailsBook](http://a-chacon.com/oas_rails/book)
486
43
 
487
44
  ## Contributing
488
45
 
@@ -496,17 +53,6 @@ If you plan a big feature, first open an issue to discuss it before any developm
496
53
  4. Push to the Branch (`git push origin feature/AmazingFeature`)
497
54
  5. Open a Pull Request
498
55
 
499
- ### Roadmap and Ideas for Improvement
500
-
501
- - [ ] Clean, document and structure the code
502
- - [x] Support documentation of authentication methods
503
- - [ ] Define Global Tags/Configuration (e.g., common responses like 404 errors)
504
- - [ ] Post-process the JSON and replace common objects with references to components
505
- - [ ] Create a temporary file with the JSON in production mode to avoid rebuilding it on every request
506
- - [ ] Create tags for popular gems used in APIs (e.g., a `@pagy` tag for common pagination parameters)
507
- - [x] Add basic authentication to OAS and UI for security reasons (Solution documented, not need to be managed by the engine)
508
- - [ ] Implement ability to define OAS by namespaces (e.g., generate OAS for specific routes like `/api` or separate versions V1 and V2)
509
-
510
56
  ## License
511
57
 
512
58
  The gem is available as open source under the terms of the [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.en.html#license-text).
@@ -6,21 +6,133 @@
6
6
  <%= csp_meta_tag %>
7
7
  <meta charset="utf-8">
8
8
  <!-- Important: rapi-doc uses utf8 characters -->
9
- <script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
9
+ <script type="module" src="/oas-rails-assets/rapidoc-min.js"></script>
10
+ <script>
11
+ function applyTheme() {
12
+ const theme = "<%= OasRails.config.rapidoc_theme %>";
13
+ const docEl = document.querySelector('rapi-doc');
14
+
15
+ // Reset all theme-related attributes
16
+ docEl.removeAttribute('theme');
17
+ docEl.removeAttribute('bg-color');
18
+ docEl.removeAttribute('text-color');
19
+ docEl.removeAttribute('nav-bg-color');
20
+ docEl.removeAttribute('nav-text-color');
21
+ docEl.removeAttribute('nav-hover-bg-color');
22
+ docEl.removeAttribute('nav-hover-text-color');
23
+ docEl.removeAttribute('nav-accent-color');
24
+ docEl.removeAttribute('primary-color');
25
+
26
+ console.log(theme === 'dark')
27
+
28
+ if (theme === 'dark'){
29
+ docEl.setAttribute('theme','dark');
30
+ docEl.setAttribute('bg-color','#333');
31
+ docEl.setAttribute('text-color','#BBB');
32
+ } else if (theme === 'light'){
33
+ docEl.setAttribute('theme','light');
34
+ docEl.setAttribute('bg-color','#FFF');
35
+ docEl.setAttribute('text-color','#444');
36
+ } else if (theme === 'night') {
37
+ docEl.setAttribute('theme','dark');
38
+ docEl.setAttribute('bg-color','#14191f');
39
+ docEl.setAttribute('text-color','#aec2e0');
40
+ } else if (theme === 'mud') {
41
+ docEl.setAttribute('theme','dark');
42
+ docEl.setAttribute('bg-color','#403635');
43
+ docEl.setAttribute('text-color','#c3b8b7');
44
+ } else if (theme === 'cofee') {
45
+ docEl.setAttribute('theme','dark');
46
+ docEl.setAttribute('bg-color','#36312C');
47
+ docEl.setAttribute('text-color','#ceb8a0');
48
+ } else if (theme === 'forest') {
49
+ docEl.setAttribute('theme','dark');
50
+ docEl.setAttribute('bg-color','#384244');
51
+ docEl.setAttribute('text-color','#BDD6DB');
52
+ } else if (theme === 'olive') {
53
+ docEl.setAttribute('theme','dark');
54
+ docEl.setAttribute('bg-color','#2a2f31');
55
+ docEl.setAttribute('text-color','#acc7c8');
56
+ } else if (theme === 'outerspace') {
57
+ docEl.setAttribute('theme','dark');
58
+ docEl.setAttribute('bg-color','#2D3133');
59
+ docEl.setAttribute('text-color','#CAD9E3');
60
+ } else if (theme === 'ebony') {
61
+ docEl.setAttribute('theme','dark');
62
+ docEl.setAttribute('bg-color','#2B303B');
63
+ docEl.setAttribute('text-color','#dee3ec');
64
+ } else if (theme === 'snow') {
65
+ docEl.setAttribute('theme','light');
66
+ docEl.setAttribute('bg-color','#FAFAFA');
67
+ docEl.setAttribute('text-color','#555');
68
+ } else if (theme === 'green') {
69
+ docEl.setAttribute('theme','light');
70
+ docEl.setAttribute('bg-color','#f9fdf7');
71
+ docEl.setAttribute('text-color','#375F1B');
72
+ } else if (theme === 'blue') {
73
+ docEl.setAttribute('theme','light');
74
+ docEl.setAttribute('bg-color','#ecf1f7');
75
+ docEl.setAttribute('text-color','#133863');
76
+ } else if (theme === 'beige') {
77
+ docEl.setAttribute('show-header','true');
78
+ docEl.setAttribute('theme','light');
79
+ docEl.setAttribute('bg-color','#fdf8ed');
80
+ docEl.setAttribute('text-color','#342809');
81
+ } else if (theme === 'graynav') {
82
+ docEl.setAttribute('show-header','false');
83
+ docEl.setAttribute('theme','light');
84
+ docEl.setAttribute('nav-bg-color','#3e4b54');
85
+ docEl.setAttribute('nav-accent-color','#fd6964');
86
+ docEl.setAttribute('primary-color','#ea526f');
87
+ } else if (theme === 'purplenav') {
88
+ docEl.setAttribute('show-header','false');
89
+ docEl.setAttribute('theme','light');
90
+ docEl.setAttribute('nav-accent-color','#ffd8e7');
91
+ docEl.setAttribute('nav-bg-color','#666699');
92
+ docEl.setAttribute('primary-color','#ea526f');
93
+ docEl.setAttribute('bg-color','#fff9fb');
94
+ } else if (theme === 'lightgraynav') {
95
+ docEl.setAttribute('show-header','false');
96
+ docEl.setAttribute('theme','light');
97
+ docEl.setAttribute('nav-bg-color','#fafafa');
98
+ docEl.setAttribute('nav-hover-text-color','#9b0700');
99
+ docEl.setAttribute('nav-hover-bg-color','#ffebea');
100
+ docEl.setAttribute('primary-color','#F63C41');
101
+ docEl.setAttribute('bg-color','#ffffff');
102
+ } else if (theme === 'darkbluenav') {
103
+ docEl.setAttribute('show-header','false');
104
+ docEl.setAttribute('theme','light');
105
+ docEl.setAttribute('bg-color','#f9f9fa');
106
+ docEl.setAttribute('nav-bg-color','#3f4d67');
107
+ docEl.setAttribute('nav-text-color','#a9b7d0');
108
+ docEl.setAttribute('nav-hover-bg-color','#333f54');
109
+ docEl.setAttribute('nav-hover-text-color','#fff');
110
+ docEl.setAttribute('nav-accent-color','#f87070');
111
+ docEl.setAttribute('primary-color','#5c7096');
112
+ } else if (theme === 'rails') {
113
+ docEl.setAttribute('theme','light');
114
+ docEl.setAttribute('bg-color','#FFFFFF');
115
+ docEl.setAttribute('nav-bg-color','#101828');
116
+ docEl.setAttribute('nav-text-color','#fff');
117
+ docEl.setAttribute('nav-hover-bg-color','#261B23');
118
+ docEl.setAttribute('nav-hover-text-color','#fff');
119
+ docEl.setAttribute('nav-accent-color','#D30001');
120
+ docEl.setAttribute('primary-color','#D30001');
121
+ }
122
+ }
123
+
124
+ document.addEventListener('DOMContentLoaded', applyTheme);
125
+ </script>
10
126
  </head>
11
127
  <body>
12
128
  <rapi-doc
13
129
  spec-url="<%= OasRails::Engine.routes.find_script_name({}) %>.json"
14
- theme="dark"
15
- bg-color="#0F172A"
16
- text-color="#f7f7f7"
17
130
  show-header="false"
18
- primary-color="#2de410"
19
131
  font-size="largest"
20
132
  show-method-in-nav-bar="as-colored-text"
21
- nav-text-color="#f7f7f7"
22
133
  nav-item-spacing="relaxed"
23
134
  allow-spec-file-download="true"
135
+ schema-style="table"
24
136
  >
25
137
  </rapi-doc>
26
138
 
@@ -68,7 +68,7 @@ OasRails.configure do |config|
68
68
  # Default: false
69
69
  # config.layout = "application"
70
70
 
71
- # Excluding custom controlers or controlers#action
71
+ # Excluding custom controllers or controllers#action
72
72
  # Example: ["projects", "users#new"]
73
73
  # config.ignored_actions = []
74
74
 
@@ -77,7 +77,7 @@ OasRails.configure do |config|
77
77
  # #######################
78
78
 
79
79
  # Whether to authenticate all routes by default
80
- # Default is true; set to false if you don't want all routes to include secutrity schemas by default
80
+ # Default is true; set to false if you don't want all routes to include security schemas by default
81
81
  # config.authenticate_all_routes_by_default = true
82
82
 
83
83
  # Default security schema used for authentication
@@ -101,7 +101,7 @@ OasRails.configure do |config|
101
101
  # Default Responses (Errors)
102
102
  # ###########################
103
103
 
104
- # The default responses errors are setted only if the action allow it.
104
+ # The default responses errors are set only if the action allow it.
105
105
  # Example, if you add forbidden then it will be added only if the endpoint requires authentication.
106
106
  # Example: not_found will be setted to the endpoint only if the operation is a show/update/destroy action.
107
107
  # config.set_default_responses = true