jsapi 1.2 → 1.4
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 +4 -4
- data/lib/jsapi/configuration.rb +2 -2
- data/lib/jsapi/controller/methods.rb +17 -4
- data/lib/jsapi/controller/parameters.rb +26 -13
- data/lib/jsapi/controller/response.rb +29 -5
- data/lib/jsapi/dsl/class_methods.rb +11 -0
- data/lib/jsapi/dsl/definitions.rb +14 -0
- data/lib/jsapi/dsl/path.rb +43 -0
- data/lib/jsapi/dsl.rb +1 -0
- data/lib/jsapi/meta/callback/base.rb +1 -1
- data/lib/jsapi/meta/definitions.rb +98 -24
- data/lib/jsapi/meta/example/base.rb +4 -6
- data/lib/jsapi/meta/link/base.rb +4 -2
- data/lib/jsapi/meta/oauth_flow.rb +11 -2
- data/lib/jsapi/meta/openapi/path_item.rb +68 -0
- data/lib/jsapi/meta/openapi/version.rb +6 -0
- data/lib/jsapi/meta/openapi.rb +2 -0
- data/lib/jsapi/meta/operation.rb +29 -17
- data/lib/jsapi/meta/parameter/base.rb +82 -59
- data/lib/jsapi/meta/path.rb +56 -0
- data/lib/jsapi/meta/pathname.rb +60 -0
- data/lib/jsapi/meta/request_body/base.rb +3 -2
- data/lib/jsapi/meta/response/base.rb +26 -8
- data/lib/jsapi/meta/schema/base.rb +1 -1
- data/lib/jsapi/meta/schema/discriminator.rb +14 -4
- data/lib/jsapi/meta/schema/object.rb +28 -9
- data/lib/jsapi/meta/schema/validation/maximum.rb +1 -1
- data/lib/jsapi/meta/schema/validation/minimum.rb +1 -1
- data/lib/jsapi/meta/security_scheme/api_key.rb +4 -5
- data/lib/jsapi/meta/security_scheme/base.rb +16 -0
- data/lib/jsapi/meta/security_scheme/http/basic.rb +3 -10
- data/lib/jsapi/meta/security_scheme/http/bearer.rb +8 -8
- data/lib/jsapi/meta/security_scheme/http/other.rb +3 -5
- data/lib/jsapi/meta/security_scheme/mutual_tls.rb +23 -0
- data/lib/jsapi/meta/security_scheme/oauth2.rb +29 -13
- data/lib/jsapi/meta/security_scheme/open_id_connect.rb +5 -8
- data/lib/jsapi/meta/security_scheme.rb +3 -0
- data/lib/jsapi/meta/server.rb +9 -1
- data/lib/jsapi/meta/tag.rb +34 -4
- data/lib/jsapi/meta.rb +2 -0
- data/lib/jsapi/version.rb +1 -1
- metadata +7 -2
|
@@ -8,6 +8,22 @@ module Jsapi
|
|
|
8
8
|
# :attr: description
|
|
9
9
|
# The description of the security scheme.
|
|
10
10
|
attribute :description, String
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# :attr: deprecated
|
|
14
|
+
# Specifies whether or not the security scheme is deprecated.
|
|
15
|
+
# Applies to \OpenAPI 3.2 and higher.
|
|
16
|
+
attribute :deprecated, values: [true, false]
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def base_openapi_fields(type, version)
|
|
21
|
+
{
|
|
22
|
+
type: type,
|
|
23
|
+
description: description,
|
|
24
|
+
deprecated: (deprecated?.presence if version >= OpenAPI::V3_2)
|
|
25
|
+
}
|
|
26
|
+
end
|
|
11
27
|
end
|
|
12
28
|
end
|
|
13
29
|
end
|
|
@@ -13,17 +13,10 @@ module Jsapi
|
|
|
13
13
|
version = OpenAPI::Version.from(version)
|
|
14
14
|
|
|
15
15
|
with_openapi_extensions(
|
|
16
|
-
if version
|
|
17
|
-
|
|
18
|
-
type: 'basic',
|
|
19
|
-
description: description
|
|
20
|
-
}
|
|
16
|
+
if version < OpenAPI::V3_0
|
|
17
|
+
base_openapi_fields('basic', version)
|
|
21
18
|
else
|
|
22
|
-
|
|
23
|
-
type: 'http',
|
|
24
|
-
scheme: 'basic',
|
|
25
|
-
description: description
|
|
26
|
-
}
|
|
19
|
+
base_openapi_fields('http', version).merge(scheme: 'basic')
|
|
27
20
|
end
|
|
28
21
|
)
|
|
29
22
|
end
|
|
@@ -7,7 +7,7 @@ module Jsapi
|
|
|
7
7
|
# Specifies a security scheme based on bearer authentication.
|
|
8
8
|
#
|
|
9
9
|
# Note that Bearer authentication was introduced with \OpenAPI 3.0. Thus, a security
|
|
10
|
-
# scheme of this class is
|
|
10
|
+
# scheme of this class is omitted when generating an \OpenAPI 2.0 document.
|
|
11
11
|
class Bearer < Base
|
|
12
12
|
include OpenAPI::Extensions
|
|
13
13
|
|
|
@@ -16,17 +16,17 @@ module Jsapi
|
|
|
16
16
|
# The format of the bearer token.
|
|
17
17
|
attribute :bearer_format, String
|
|
18
18
|
|
|
19
|
-
# Returns a hash representing the \OpenAPI security scheme object, or
|
|
20
|
-
#
|
|
19
|
+
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
|
20
|
+
# if <code>version</code> is less than \OpenAPI 3.0.
|
|
21
21
|
def to_openapi(version, *)
|
|
22
22
|
version = OpenAPI::Version.from(version)
|
|
23
|
-
return if version
|
|
23
|
+
return if version < OpenAPI::V3_0
|
|
24
24
|
|
|
25
25
|
with_openapi_extensions(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
base_openapi_fields('http', version).merge(
|
|
27
|
+
scheme: 'bearer',
|
|
28
|
+
bearerFormat: bearer_format
|
|
29
|
+
)
|
|
30
30
|
)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -18,15 +18,13 @@ module Jsapi
|
|
|
18
18
|
attribute :scheme, String
|
|
19
19
|
|
|
20
20
|
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
|
21
|
-
# if <code>version
|
|
21
|
+
# if <code>version</code> is less than \OpenAPI 3.0.
|
|
22
22
|
def to_openapi(version, *)
|
|
23
23
|
version = OpenAPI::Version.from(version)
|
|
24
|
-
return if version
|
|
24
|
+
return if version < OpenAPI::V3_0
|
|
25
25
|
|
|
26
26
|
with_openapi_extensions(
|
|
27
|
-
|
|
28
|
-
scheme: scheme,
|
|
29
|
-
description: description
|
|
27
|
+
base_openapi_fields('http', version).merge(scheme: scheme)
|
|
30
28
|
)
|
|
31
29
|
end
|
|
32
30
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jsapi
|
|
4
|
+
module Meta
|
|
5
|
+
module SecurityScheme
|
|
6
|
+
# Specifies a security scheme based on MutualTLS.
|
|
7
|
+
class MutualTLS < Base
|
|
8
|
+
include OpenAPI::Extensions
|
|
9
|
+
|
|
10
|
+
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
|
11
|
+
# if <code>version</code> is less than \OpenAPI 3.1.
|
|
12
|
+
def to_openapi(version, *)
|
|
13
|
+
version = OpenAPI::Version.from(version)
|
|
14
|
+
return if version < OpenAPI::V3_1
|
|
15
|
+
|
|
16
|
+
with_openapi_extensions(
|
|
17
|
+
base_openapi_fields('mutualTLS', version)
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -9,34 +9,50 @@ module Jsapi
|
|
|
9
9
|
|
|
10
10
|
##
|
|
11
11
|
# :attr: oauth_flows
|
|
12
|
-
#
|
|
12
|
+
# Maps one or more of the following keys to OAuthFlow objects.
|
|
13
13
|
#
|
|
14
14
|
# - <code>"authorization_code"</code>
|
|
15
15
|
# - <code>"client_credentials"</code>
|
|
16
|
+
# - <code>"device_authorization"</code>
|
|
16
17
|
# - <code>"implicit"</code>
|
|
17
18
|
# - <code>"password"</code>
|
|
18
19
|
#
|
|
19
|
-
#
|
|
20
|
+
# Note that <code>"device_authorization"</code> was introduced with \OpenAPI 3.2.
|
|
21
|
+
# This entry is omitted when generating an \OpenAPI document with a lower version.
|
|
20
22
|
attribute :oauth_flows, { String => OAuthFlow },
|
|
21
|
-
keys: %w[authorization_code
|
|
23
|
+
keys: %w[authorization_code
|
|
24
|
+
client_credentials
|
|
25
|
+
device_authorization
|
|
26
|
+
implicit
|
|
27
|
+
password]
|
|
28
|
+
##
|
|
29
|
+
# :attr: oauth2_metadata_url
|
|
30
|
+
# The URL of the OAuth2 authorization server metadata.
|
|
31
|
+
# Applies to \OpenAPI 3.2 and higher.
|
|
32
|
+
attribute :oauth2_metadata_url, String
|
|
22
33
|
|
|
23
34
|
# Returns a hash representing the \OpenAPI security scheme object.
|
|
24
35
|
def to_openapi(version, *)
|
|
25
36
|
version = OpenAPI::Version.from(version)
|
|
26
37
|
|
|
27
|
-
with_openapi_extensions(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
h[:flows] = oauth_flows.to_h do |key, value|
|
|
38
|
+
with_openapi_extensions(
|
|
39
|
+
base_openapi_fields('oauth2', version).tap do |fields|
|
|
40
|
+
flows = oauth_flows
|
|
41
|
+
flows = flows.except('device_authorization') unless version >= OpenAPI::V3_2
|
|
42
|
+
|
|
43
|
+
if version >= OpenAPI::V3_0
|
|
44
|
+
fields[:flows] = flows.to_h do |key, value|
|
|
35
45
|
[key.to_s.camelize(:lower).to_sym, value.to_openapi(version)]
|
|
36
|
-
end
|
|
46
|
+
end if flows.any?
|
|
47
|
+
|
|
48
|
+
fields[:oauth2MetadataUrl] = oauth2_metadata_url if version >= OpenAPI::V3_2
|
|
49
|
+
elsif flows.one?
|
|
50
|
+
key, flow = flows.first
|
|
51
|
+
fields[:flow] = key.to_s
|
|
52
|
+
fields.merge!(flow.to_openapi(version))
|
|
37
53
|
end
|
|
38
54
|
end
|
|
39
|
-
|
|
55
|
+
)
|
|
40
56
|
end
|
|
41
57
|
end
|
|
42
58
|
end
|
|
@@ -4,9 +4,6 @@ module Jsapi
|
|
|
4
4
|
module Meta
|
|
5
5
|
module SecurityScheme
|
|
6
6
|
# Specifies a security scheme based on OpenID Connect.
|
|
7
|
-
#
|
|
8
|
-
# OpenID Connect was introduced with \OpenAPI 3.0. Thus, a security scheme of
|
|
9
|
-
# this class is skipped when generating an \OpenAPI 2.0 document.
|
|
10
7
|
class OpenIDConnect < Base
|
|
11
8
|
include OpenAPI::Extensions
|
|
12
9
|
|
|
@@ -15,15 +12,15 @@ module Jsapi
|
|
|
15
12
|
attribute :open_id_connect_url, String
|
|
16
13
|
|
|
17
14
|
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
|
18
|
-
# if <code>version
|
|
15
|
+
# if <code>version</code> is less than \OpenAPI 3.0.
|
|
19
16
|
def to_openapi(version, *)
|
|
20
17
|
version = OpenAPI::Version.from(version)
|
|
21
|
-
return if version
|
|
18
|
+
return if version < OpenAPI::V3_0
|
|
22
19
|
|
|
23
20
|
with_openapi_extensions(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
base_openapi_fields('openIdConnect', version).merge(
|
|
22
|
+
openIdConnectUrl: open_id_connect_url
|
|
23
|
+
)
|
|
27
24
|
)
|
|
28
25
|
end
|
|
29
26
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative 'security_scheme/base'
|
|
4
4
|
require_relative 'security_scheme/api_key'
|
|
5
5
|
require_relative 'security_scheme/http'
|
|
6
|
+
require_relative 'security_scheme/mutual_tls'
|
|
6
7
|
require_relative 'security_scheme/oauth2'
|
|
7
8
|
require_relative 'security_scheme/open_id_connect'
|
|
8
9
|
|
|
@@ -31,6 +32,8 @@ module Jsapi
|
|
|
31
32
|
HTTP.new(keywords.merge(scheme: 'basic'))
|
|
32
33
|
when 'http' # OpenAPI 3.0 and higher
|
|
33
34
|
HTTP.new(keywords)
|
|
35
|
+
when 'mutual_tls' # OpenAPI 3.1 and higher
|
|
36
|
+
MutualTLS.new(keywords)
|
|
34
37
|
when 'oauth2'
|
|
35
38
|
OAuth2.new(keywords)
|
|
36
39
|
when 'open_id_connect' # OpenAPI 3.0 and higher
|
data/lib/jsapi/meta/server.rb
CHANGED
|
@@ -11,6 +11,11 @@ module Jsapi
|
|
|
11
11
|
# The description of the server.
|
|
12
12
|
attribute :description, String
|
|
13
13
|
|
|
14
|
+
##
|
|
15
|
+
# :attr: name
|
|
16
|
+
# The optional unique name of the server. Applies to \OpenAPI 3.2 and higher.
|
|
17
|
+
attribute :name, String
|
|
18
|
+
|
|
14
19
|
##
|
|
15
20
|
# :attr: url
|
|
16
21
|
# The absolute or relative URL of the server.
|
|
@@ -22,10 +27,13 @@ module Jsapi
|
|
|
22
27
|
attribute :variables, { String => ServerVariable }
|
|
23
28
|
|
|
24
29
|
# Returns a hash representing the \OpenAPI server object.
|
|
25
|
-
def to_openapi(*)
|
|
30
|
+
def to_openapi(version, *)
|
|
31
|
+
version = OpenAPI::Version.from(version)
|
|
32
|
+
|
|
26
33
|
with_openapi_extensions(
|
|
27
34
|
url: url,
|
|
28
35
|
description: description,
|
|
36
|
+
name: (name if version >= OpenAPI::V3_2),
|
|
29
37
|
variables: variables.transform_values(&:to_openapi).presence
|
|
30
38
|
)
|
|
31
39
|
end
|
data/lib/jsapi/meta/tag.rb
CHANGED
|
@@ -16,17 +16,47 @@ module Jsapi
|
|
|
16
16
|
# The ExternalDocumentation object.
|
|
17
17
|
attribute :external_docs, ExternalDocumentation
|
|
18
18
|
|
|
19
|
+
##
|
|
20
|
+
# :attr: kind
|
|
21
|
+
# The category of the tag. Applies to \OpenAPI 3.2 and higher.
|
|
22
|
+
attribute :kind, String
|
|
23
|
+
|
|
19
24
|
##
|
|
20
25
|
# :attr: name
|
|
21
26
|
# The name of the tag.
|
|
22
27
|
attribute :name, String
|
|
23
28
|
|
|
29
|
+
##
|
|
30
|
+
# :attr: parent
|
|
31
|
+
# The name of the parent tag. Applies to \OpenAPI 3.2 and higher.
|
|
32
|
+
attribute :parent, String
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# :attr: summary
|
|
36
|
+
# The short summary of the tag. Applies to \OpenAPI 3.2 and higher.
|
|
37
|
+
attribute :summary, String
|
|
38
|
+
|
|
24
39
|
# Returns a hash representing the \OpenAPI tag object.
|
|
25
|
-
def to_openapi(*)
|
|
40
|
+
def to_openapi(version, *)
|
|
41
|
+
version = OpenAPI::Version.from(version)
|
|
42
|
+
|
|
26
43
|
with_openapi_extensions(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
if version >= OpenAPI::V3_2
|
|
45
|
+
{
|
|
46
|
+
name: name,
|
|
47
|
+
summary: summary,
|
|
48
|
+
description: description,
|
|
49
|
+
externalDocs: external_docs&.to_openapi,
|
|
50
|
+
parent: parent,
|
|
51
|
+
kind: kind
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
{
|
|
55
|
+
name: name,
|
|
56
|
+
description: description,
|
|
57
|
+
externalDocs: external_docs&.to_openapi
|
|
58
|
+
}
|
|
59
|
+
end
|
|
30
60
|
)
|
|
31
61
|
end
|
|
32
62
|
end
|
data/lib/jsapi/meta.rb
CHANGED
|
@@ -24,6 +24,8 @@ require_relative 'meta/property'
|
|
|
24
24
|
require_relative 'meta/schema'
|
|
25
25
|
require_relative 'meta/request_body'
|
|
26
26
|
require_relative 'meta/parameter'
|
|
27
|
+
require_relative 'meta/pathname'
|
|
28
|
+
require_relative 'meta/path'
|
|
27
29
|
require_relative 'meta/response'
|
|
28
30
|
require_relative 'meta/operation'
|
|
29
31
|
require_relative 'meta/rescue_handler'
|
data/lib/jsapi/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.4'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Göller
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: denis@dmgoeller.de
|
|
@@ -34,6 +34,7 @@ files:
|
|
|
34
34
|
- lib/jsapi/dsl/examples.rb
|
|
35
35
|
- lib/jsapi/dsl/operation.rb
|
|
36
36
|
- lib/jsapi/dsl/parameter.rb
|
|
37
|
+
- lib/jsapi/dsl/path.rb
|
|
37
38
|
- lib/jsapi/dsl/request_body.rb
|
|
38
39
|
- lib/jsapi/dsl/response.rb
|
|
39
40
|
- lib/jsapi/dsl/schema.rb
|
|
@@ -80,11 +81,14 @@ files:
|
|
|
80
81
|
- lib/jsapi/meta/oauth_flow.rb
|
|
81
82
|
- lib/jsapi/meta/openapi.rb
|
|
82
83
|
- lib/jsapi/meta/openapi/extensions.rb
|
|
84
|
+
- lib/jsapi/meta/openapi/path_item.rb
|
|
83
85
|
- lib/jsapi/meta/openapi/version.rb
|
|
84
86
|
- lib/jsapi/meta/operation.rb
|
|
85
87
|
- lib/jsapi/meta/parameter.rb
|
|
86
88
|
- lib/jsapi/meta/parameter/base.rb
|
|
87
89
|
- lib/jsapi/meta/parameter/reference.rb
|
|
90
|
+
- lib/jsapi/meta/path.rb
|
|
91
|
+
- lib/jsapi/meta/pathname.rb
|
|
88
92
|
- lib/jsapi/meta/property.rb
|
|
89
93
|
- lib/jsapi/meta/reference_error.rb
|
|
90
94
|
- lib/jsapi/meta/request_body.rb
|
|
@@ -128,6 +132,7 @@ files:
|
|
|
128
132
|
- lib/jsapi/meta/security_scheme/http/basic.rb
|
|
129
133
|
- lib/jsapi/meta/security_scheme/http/bearer.rb
|
|
130
134
|
- lib/jsapi/meta/security_scheme/http/other.rb
|
|
135
|
+
- lib/jsapi/meta/security_scheme/mutual_tls.rb
|
|
131
136
|
- lib/jsapi/meta/security_scheme/oauth2.rb
|
|
132
137
|
- lib/jsapi/meta/security_scheme/open_id_connect.rb
|
|
133
138
|
- lib/jsapi/meta/server.rb
|