rodauth-openapi 0.1.0 → 0.1.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: 0ce74f8234f280f924c119e914ee31e88ee7714ccd10770626de4034edcac7da
4
- data.tar.gz: 42f9cd22c79d36a6ae06e4703ce80a0da926908e5bd72f4eeb0a77644db1cf68
3
+ metadata.gz: a86dd14abeb963d0eebce7cda224b27079e8baec4afef8a26dd8835d61a6d1c2
4
+ data.tar.gz: de83fbc7157062e19dddf785fdb133ba2d32082e7bee857bba211b0a43d6dba2
5
5
  SHA512:
6
- metadata.gz: e3797f271d6735174e03beda40c98f2392a338d295dcb15d06d323d52cc8828a1b0c654d798a8c3380039759a7eb769f8c9747ad4a7f0678a0f293e07eaa16de
7
- data.tar.gz: bbdd36a6a8ab3d499b4f2af8487291111084e7a51851ef3e5463b861a6118922a20d217e2f5e56c185ca74e8f2a2b01b50d9694cbebd1f6312bf51cb18316b84
6
+ metadata.gz: 2099f86cb751e6288cded721a96477702e33f1f671958576da458dbb3283352f0d3ed3f9d1034a5778790436b86628b6ee394d96b12bb9f393beb0d29d43dbdd
7
+ data.tar.gz: 38833efb47e16efcf639549e166ada6d4735baa7c54f619cf873e71e378d3e4ac7cbd19588de63afef436a00e225bf0a3a2b94af3aee48403d6b1ae01b11b623
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rodauth OpenAPI
2
2
 
3
- Generates [OpenAPI] documentation for your Rodauth endpoints.
3
+ Generate [OpenAPI] documentation for your Rodauth endpoints.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,7 +12,7 @@ bundle add rodauth-openapi --group development
12
12
 
13
13
  The generated OpenAPI documentation can be uploaded to renderers such as [Swagger Editor] or [Redoc].
14
14
 
15
- ### Rails
15
+ ### In Rails
16
16
 
17
17
  Assuming you have Rodauth installed in your Rails application, you can use the generator provided by this gem:
18
18
 
@@ -45,22 +45,15 @@ open_api = Rodauth::OpenAPI.new(auth_class)
45
45
  File.write("openapi.yml", open_api.to_yaml)
46
46
  ```
47
47
 
48
- To generate JSON API endpoints:
48
+ Here are the various options and methods supported:
49
49
 
50
50
  ```rb
51
- Roduath::OpenAPI.new(auth_class, json: true)
52
- ```
53
-
54
- To assume the account doesn't have a password:
51
+ Rodauth::OpenAPI.new(auth_class, json: true) # generate JSON API endpoints
52
+ Rodauth::OpenAPI.new(auth_class, password: false) # assume account has no password
55
53
 
56
- ```rb
57
- Roduath::OpenAPI.new(auth_class, password: false)
58
- ```
59
-
60
- To generate the documentation in JSON format:
61
-
62
- ```rb
63
- Roduath::OpenAPI.new(auth_class).to_json
54
+ Rodauth::OpenAPI.new(auth_class).to_yaml # YAML format
55
+ Rodauth::OpenAPI.new(auth_class).to_json # JSON format
56
+ Rodauth::OpenAPI.new(auth_class).generate # ruby hash
64
57
  ```
65
58
 
66
59
  ## License
@@ -30,6 +30,8 @@ module Rodauth
30
30
  else
31
31
  puts documentation
32
32
  end
33
+ rescue Rodauth::OpenAPI::Error => error
34
+ say error.message, :red
33
35
  end
34
36
 
35
37
  private
@@ -5,6 +5,8 @@ require "rodauth/openapi/routes"
5
5
 
6
6
  module Rodauth
7
7
  class OpenAPI
8
+ Error = Class.new(StandardError)
9
+
8
10
  DOCS_URL = "https://rodauth.jeremyevans.net/documentation.html"
9
11
  SPEC_VERSION = "3.0.1"
10
12
 
@@ -23,6 +25,10 @@ module Rodauth
23
25
  end
24
26
 
25
27
  def generate
28
+ if json? && !rodauth.features.include?(:json)
29
+ fail Error, "JSON API documentation was requested, but JSON feature is not enabled"
30
+ end
31
+
26
32
  data = {
27
33
  openapi: SPEC_VERSION,
28
34
  info: {
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "rodauth-openapi"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko.marohnic@gmail.com"]
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rodauth