jsapi 0.2.0 → 0.4.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 +4 -4
- data/lib/jsapi/controller/methods.rb +13 -3
- data/lib/jsapi/controller/parameters.rb +2 -5
- data/lib/jsapi/controller/response.rb +46 -24
- data/lib/jsapi/dsl/class_methods.rb +5 -0
- data/lib/jsapi/dsl/definitions.rb +7 -0
- data/lib/jsapi/json/object.rb +5 -8
- data/lib/jsapi/meta/definitions.rb +20 -11
- data/lib/jsapi/meta/openapi/callback/model.rb +1 -1
- data/lib/jsapi/meta/openapi/contact.rb +4 -6
- data/lib/jsapi/meta/openapi/example/model.rb +44 -0
- data/lib/jsapi/meta/openapi/example/reference.rb +16 -0
- data/lib/jsapi/meta/openapi/example.rb +21 -0
- data/lib/jsapi/meta/openapi/extensions.rb +31 -0
- data/lib/jsapi/meta/openapi/external_documentation.rb +4 -5
- data/lib/jsapi/meta/openapi/header/model.rb +64 -0
- data/lib/jsapi/meta/openapi/header/reference.rb +16 -0
- data/lib/jsapi/meta/openapi/header.rb +21 -0
- data/lib/jsapi/meta/openapi/info.rb +5 -3
- data/lib/jsapi/meta/openapi/license.rb +4 -5
- data/lib/jsapi/meta/openapi/link/model.rb +5 -3
- data/lib/jsapi/meta/openapi/oauth_flow.rb +5 -3
- data/lib/jsapi/meta/openapi/root.rb +44 -32
- data/lib/jsapi/meta/openapi/security_requirement.rb +1 -1
- data/lib/jsapi/meta/openapi/security_scheme/api_key.rb +5 -3
- data/lib/jsapi/meta/openapi/security_scheme/http/basic.rb +18 -13
- data/lib/jsapi/meta/openapi/security_scheme/http/bearer.rb +5 -3
- data/lib/jsapi/meta/openapi/security_scheme/http/other.rb +5 -3
- data/lib/jsapi/meta/openapi/security_scheme/oauth2.rb +6 -6
- data/lib/jsapi/meta/openapi/security_scheme/open_id_connect.rb +5 -3
- data/lib/jsapi/meta/openapi/server.rb +5 -3
- data/lib/jsapi/meta/openapi/server_variable.rb +5 -3
- data/lib/jsapi/meta/openapi/tag.rb +5 -3
- data/lib/jsapi/meta/openapi.rb +3 -0
- data/lib/jsapi/meta/operation.rb +6 -3
- data/lib/jsapi/meta/parameter/model.rb +54 -48
- data/lib/jsapi/meta/request_body/model.rb +6 -4
- data/lib/jsapi/meta/response/model.rb +37 -23
- data/lib/jsapi/meta/schema/additional_properties.rb +29 -0
- data/lib/jsapi/meta/schema/base.rb +34 -29
- data/lib/jsapi/meta/schema/object.rb +9 -1
- data/lib/jsapi/meta/schema.rb +2 -1
- data/lib/jsapi/meta.rb +0 -1
- data/lib/jsapi/version.rb +1 -1
- metadata +10 -5
- data/lib/jsapi/meta/example/model.rb +0 -43
- data/lib/jsapi/meta/example/reference.rb +0 -14
- data/lib/jsapi/meta/example.rb +0 -19
@@ -5,6 +5,8 @@ module Jsapi
|
|
5
5
|
module OpenAPI
|
6
6
|
# Represents an \OpenAPI object.
|
7
7
|
class Root < Base
|
8
|
+
include Extensions
|
9
|
+
|
8
10
|
##
|
9
11
|
# :attr: callbacks
|
10
12
|
# The reusable Callback objects. Applies to \OpenAPI 3.0 and higher.
|
@@ -29,6 +31,11 @@ module Jsapi
|
|
29
31
|
# The optional ExternalDocumentation object.
|
30
32
|
attribute :external_docs, ExternalDocumentation
|
31
33
|
|
34
|
+
##
|
35
|
+
# :attr: headers
|
36
|
+
# The reusable Header objects. Applies to \OpenAPI 3.0 and higher.
|
37
|
+
attribute :headers, { String => Header }
|
38
|
+
|
32
39
|
##
|
33
40
|
# :attr: host
|
34
41
|
# The host serving the API. Applies to \OpenAPI 2.0.
|
@@ -95,38 +102,43 @@ module Jsapi
|
|
95
102
|
value.to_openapi(version)
|
96
103
|
end
|
97
104
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
callback
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
105
|
+
with_openapi_extensions(
|
106
|
+
if version.major == 2
|
107
|
+
uri = servers&.first&.then { |server| URI(server.url) }
|
108
|
+
{
|
109
|
+
swagger: '2.0',
|
110
|
+
info: info&.to_openapi,
|
111
|
+
host: host || uri&.hostname,
|
112
|
+
basePath: base_path || uri&.path,
|
113
|
+
schemes: schemes || uri&.scheme&.then { |scheme| [scheme] },
|
114
|
+
consumes: consumed_mime_types,
|
115
|
+
produces: produced_mime_types,
|
116
|
+
securityDefinitions: security_schemes,
|
117
|
+
security: security_requirements&.map(&:to_openapi),
|
118
|
+
tags: tags&.map(&:to_openapi),
|
119
|
+
externalDocs: external_docs&.to_openapi
|
120
|
+
}
|
121
|
+
else
|
122
|
+
{
|
123
|
+
openapi: version.minor.zero? ? '3.0.3' : '3.1.0',
|
124
|
+
info: info&.to_openapi,
|
125
|
+
servers: servers&.map(&:to_openapi),
|
126
|
+
components: {
|
127
|
+
callbacks: callbacks&.transform_values do |callback|
|
128
|
+
callback.to_openapi(version, definitions)
|
129
|
+
end,
|
130
|
+
headers: headers&.transform_values do |header|
|
131
|
+
header.to_openapi(version)
|
132
|
+
end,
|
133
|
+
links: links&.transform_values(&:to_openapi),
|
134
|
+
securitySchemes: security_schemes
|
135
|
+
}.compact.presence,
|
136
|
+
security: security_requirements&.map(&:to_openapi),
|
137
|
+
tags: tags&.map(&:to_openapi),
|
138
|
+
externalDocs: external_docs&.to_openapi
|
139
|
+
}
|
140
|
+
end
|
141
|
+
)
|
130
142
|
end
|
131
143
|
end
|
132
144
|
end
|
@@ -17,7 +17,7 @@ module Jsapi
|
|
17
17
|
# The schemes.
|
18
18
|
attribute :schemes, { String => Scheme }
|
19
19
|
|
20
|
-
# Returns a hash representing the security requirement object.
|
20
|
+
# Returns a hash representing the \OpenAPI security requirement object.
|
21
21
|
def to_openapi(*)
|
22
22
|
schemes&.transform_values(&:scopes) || {}
|
23
23
|
end
|
@@ -6,6 +6,8 @@ module Jsapi
|
|
6
6
|
module SecurityScheme
|
7
7
|
# Represents a security scheme based on an API key.
|
8
8
|
class APIKey < Base
|
9
|
+
include Extensions
|
10
|
+
|
9
11
|
##
|
10
12
|
# :attr: in
|
11
13
|
# The location of the API key. Possible values are:
|
@@ -22,14 +24,14 @@ module Jsapi
|
|
22
24
|
# API key is sent by.
|
23
25
|
attribute :name, String
|
24
26
|
|
25
|
-
# Returns a hash representing the security scheme object.
|
27
|
+
# Returns a hash representing the \OpenAPI security scheme object.
|
26
28
|
def to_openapi(*)
|
27
|
-
|
29
|
+
with_openapi_extensions(
|
28
30
|
type: 'apiKey',
|
29
31
|
name: name,
|
30
32
|
in: self.in,
|
31
33
|
description: description
|
32
|
-
|
34
|
+
)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -7,21 +7,26 @@ module Jsapi
|
|
7
7
|
module HTTP
|
8
8
|
# Represents a security scheme based on \HTTP basic authentication.
|
9
9
|
class Basic < Base
|
10
|
-
|
10
|
+
include Extensions
|
11
|
+
|
12
|
+
# Returns a hash representing the \OpenAPI security scheme object.
|
11
13
|
def to_openapi(version)
|
12
14
|
version = OpenAPI::Version.from(version)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
|
16
|
+
with_openapi_extensions(
|
17
|
+
if version.major == 2
|
18
|
+
{
|
19
|
+
type: 'basic',
|
20
|
+
description: description
|
21
|
+
}
|
22
|
+
else
|
23
|
+
{
|
24
|
+
type: 'http',
|
25
|
+
scheme: 'basic',
|
26
|
+
description: description
|
27
|
+
}
|
28
|
+
end
|
29
|
+
)
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
@@ -11,23 +11,25 @@ module Jsapi
|
|
11
11
|
# Thus, a security scheme of this class is skipped when generating
|
12
12
|
# an \OpenAPI 2.0 document.
|
13
13
|
class Bearer < Base
|
14
|
+
include Extensions
|
15
|
+
|
14
16
|
##
|
15
17
|
# :attr: bearer_format
|
16
18
|
# The optional format of the bearer token.
|
17
19
|
attribute :bearer_format, String
|
18
20
|
|
19
|
-
# Returns a hash representing the security scheme object, or
|
21
|
+
# Returns a hash representing the \OpenAPI security scheme object, or
|
20
22
|
# +nil+ if <code>version.major</code> is 2.
|
21
23
|
def to_openapi(version)
|
22
24
|
version = OpenAPI::Version.from(version)
|
23
25
|
return if version.major == 2
|
24
26
|
|
25
|
-
|
27
|
+
with_openapi_extensions(
|
26
28
|
type: 'http',
|
27
29
|
scheme: 'bearer',
|
28
30
|
bearerFormat: bearer_format,
|
29
31
|
description: description
|
30
|
-
|
32
|
+
)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -12,22 +12,24 @@ module Jsapi
|
|
12
12
|
# a security scheme of this class is skipped when generating an
|
13
13
|
# \OpenAPI 2.0 document.
|
14
14
|
class Other < Base
|
15
|
+
include Extensions
|
16
|
+
|
15
17
|
##
|
16
18
|
# :attr: scheme
|
17
19
|
# The mandatory \HTTP authentication scheme.
|
18
20
|
attribute :scheme, String
|
19
21
|
|
20
|
-
# Returns a hash representing the security scheme object, or +nil+
|
22
|
+
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
21
23
|
# if <code>version.major</code> is 2.
|
22
24
|
def to_openapi(version)
|
23
25
|
version = OpenAPI::Version.from(version)
|
24
26
|
return if version.major == 2
|
25
27
|
|
26
|
-
|
28
|
+
with_openapi_extensions(
|
27
29
|
type: 'http',
|
28
30
|
scheme: scheme,
|
29
31
|
description: description
|
30
|
-
|
32
|
+
)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -6,6 +6,8 @@ module Jsapi
|
|
6
6
|
module SecurityScheme
|
7
7
|
# Represents a security scheme based on \OAuth2.
|
8
8
|
class OAuth2 < Base
|
9
|
+
include Extensions
|
10
|
+
|
9
11
|
##
|
10
12
|
# :attr: oauth_flows
|
11
13
|
# The hash containing the OAuth flows. Possible keys are:
|
@@ -19,13 +21,11 @@ module Jsapi
|
|
19
21
|
attribute :oauth_flows, { String => OAuthFlow },
|
20
22
|
keys: %w[authorization_code client_credentials implicit password]
|
21
23
|
|
22
|
-
# Returns a hash representing the security scheme object.
|
24
|
+
# Returns a hash representing the \OpenAPI security scheme object.
|
23
25
|
def to_openapi(version)
|
24
26
|
version = Version.from(version)
|
25
|
-
|
26
|
-
|
27
|
-
description: description
|
28
|
-
}.tap do |h|
|
27
|
+
|
28
|
+
with_openapi_extensions(type: 'oauth2', description: description).tap do |h|
|
29
29
|
if oauth_flows&.any?
|
30
30
|
if version.major == 2
|
31
31
|
key, oauth_flow = oauth_flows.first
|
@@ -37,7 +37,7 @@ module Jsapi
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -9,21 +9,23 @@ module Jsapi
|
|
9
9
|
# OpenID Connect was introduced with \OpenAPI 3.0. Thus, a security scheme of
|
10
10
|
# this class is skipped when generating an \OpenAPI 2.0 document.
|
11
11
|
class OpenIDConnect < Base
|
12
|
+
include Extensions
|
13
|
+
|
12
14
|
##
|
13
15
|
# :attr: open_id_connect_url
|
14
16
|
attribute :open_id_connect_url, String
|
15
17
|
|
16
|
-
# Returns a hash representing the security scheme object, or +nil+
|
18
|
+
# Returns a hash representing the \OpenAPI security scheme object, or +nil+
|
17
19
|
# if <code>version.major</code> is 2.
|
18
20
|
def to_openapi(version)
|
19
21
|
version = Version.from(version)
|
20
22
|
return if version.major == 2
|
21
23
|
|
22
|
-
|
24
|
+
with_openapi_extensions(
|
23
25
|
type: 'openIdConnect',
|
24
26
|
openIdConnectUrl: open_id_connect_url,
|
25
27
|
description: description
|
26
|
-
|
28
|
+
)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -5,6 +5,8 @@ module Jsapi
|
|
5
5
|
module OpenAPI
|
6
6
|
# Represents a server object.
|
7
7
|
class Server < Base
|
8
|
+
include Extensions
|
9
|
+
|
8
10
|
##
|
9
11
|
# :attr: description
|
10
12
|
# The optional description of the server.
|
@@ -20,13 +22,13 @@ module Jsapi
|
|
20
22
|
# The optional server variables.
|
21
23
|
attribute :variables, { String => ServerVariable }
|
22
24
|
|
23
|
-
# Returns a hash representing the server object.
|
25
|
+
# Returns a hash representing the \OpenAPI server object.
|
24
26
|
def to_openapi(*)
|
25
|
-
|
27
|
+
with_openapi_extensions(
|
26
28
|
url: url,
|
27
29
|
description: description,
|
28
30
|
variables: variables&.transform_values(&:to_openapi)
|
29
|
-
|
31
|
+
)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -5,6 +5,8 @@ module Jsapi
|
|
5
5
|
module OpenAPI
|
6
6
|
# Represents a server variable object.
|
7
7
|
class ServerVariable < Base
|
8
|
+
include Extensions
|
9
|
+
|
8
10
|
##
|
9
11
|
# :attr: default
|
10
12
|
# The default value of the server variable.
|
@@ -20,13 +22,13 @@ module Jsapi
|
|
20
22
|
# The values of the server variable.
|
21
23
|
attribute :enum, [String]
|
22
24
|
|
23
|
-
# Returns a hash representing the server variable object.
|
25
|
+
# Returns a hash representing the \OpenAPI server variable object.
|
24
26
|
def to_openapi(*)
|
25
|
-
|
27
|
+
with_openapi_extensions(
|
26
28
|
default: default,
|
27
29
|
enum: enum.presence, # must not be empty
|
28
30
|
description: description
|
29
|
-
|
31
|
+
)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -5,6 +5,8 @@ module Jsapi
|
|
5
5
|
module OpenAPI
|
6
6
|
# Represents a tag object.
|
7
7
|
class Tag < Base
|
8
|
+
include Extensions
|
9
|
+
|
8
10
|
##
|
9
11
|
# :attr: description
|
10
12
|
# The description of the tag.
|
@@ -20,13 +22,13 @@ module Jsapi
|
|
20
22
|
# The name of the tag.
|
21
23
|
attribute :name, String
|
22
24
|
|
23
|
-
# Returns a hash representing the tag object.
|
25
|
+
# Returns a hash representing the \OpenAPI tag object.
|
24
26
|
def to_openapi(*)
|
25
|
-
|
27
|
+
with_openapi_extensions(
|
26
28
|
name: name,
|
27
29
|
description: description,
|
28
30
|
externalDocs: external_docs&.to_openapi
|
29
|
-
|
31
|
+
)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/jsapi/meta/openapi.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'openapi/extensions'
|
3
4
|
require_relative 'openapi/version'
|
4
5
|
require_relative 'openapi/callback'
|
5
6
|
require_relative 'openapi/contact'
|
6
7
|
require_relative 'openapi/license'
|
7
8
|
require_relative 'openapi/info'
|
9
|
+
require_relative 'openapi/example'
|
8
10
|
require_relative 'openapi/external_documentation'
|
11
|
+
require_relative 'openapi/header'
|
9
12
|
require_relative 'openapi/oauth_flow'
|
10
13
|
require_relative 'openapi/security_scheme'
|
11
14
|
require_relative 'openapi/security_requirement'
|
data/lib/jsapi/meta/operation.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Jsapi
|
4
4
|
module Meta
|
5
5
|
class Operation < Base
|
6
|
+
include OpenAPI::Extensions
|
7
|
+
|
6
8
|
##
|
7
9
|
# :attr: callbacks
|
8
10
|
# The optional callbacks. Applies to \OpenAPI 3.0 and higher.
|
@@ -133,7 +135,8 @@ module Jsapi
|
|
133
135
|
# Returns a hash representing the \OpenAPI operation object.
|
134
136
|
def to_openapi(version, definitions)
|
135
137
|
version = OpenAPI::Version.from(version)
|
136
|
-
|
138
|
+
|
139
|
+
with_openapi_extensions(
|
137
140
|
operationId: name,
|
138
141
|
tags: tags,
|
139
142
|
summary: summary,
|
@@ -141,7 +144,7 @@ module Jsapi
|
|
141
144
|
externalDocs: external_docs&.to_openapi,
|
142
145
|
deprecated: deprecated?.presence,
|
143
146
|
security: security_requirements&.map(&:to_openapi)
|
144
|
-
|
147
|
+
).tap do |hash|
|
145
148
|
if version.major == 2
|
146
149
|
hash[:consumes] = consumed_mime_types if consumed_mime_types
|
147
150
|
hash[:produces] = produced_mime_types if produced_mime_types
|
@@ -170,7 +173,7 @@ module Jsapi
|
|
170
173
|
callback.to_openapi(version, definitions)
|
171
174
|
end
|
172
175
|
end
|
173
|
-
end
|
176
|
+
end
|
174
177
|
end
|
175
178
|
end
|
176
179
|
end
|
@@ -4,6 +4,8 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module Parameter
|
6
6
|
class Model < Base
|
7
|
+
include OpenAPI::Extensions
|
8
|
+
|
7
9
|
##
|
8
10
|
# :attr: deprecated
|
9
11
|
# Specifies whether or not the parameter is deprecated.
|
@@ -17,7 +19,7 @@ module Jsapi
|
|
17
19
|
##
|
18
20
|
# :attr_reader: examples
|
19
21
|
# The examples.
|
20
|
-
attribute :examples, { String => Example }, default_key: 'default'
|
22
|
+
attribute :examples, { String => OpenAPI::Example }, default_key: 'default'
|
21
23
|
|
22
24
|
##
|
23
25
|
# :attr: in
|
@@ -87,32 +89,34 @@ module Jsapi
|
|
87
89
|
else
|
88
90
|
parameter_name = schema.array? ? "#{name}[]" : name
|
89
91
|
[
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
92
|
+
with_openapi_extensions(
|
93
|
+
if version.major == 2
|
94
|
+
{
|
95
|
+
name: parameter_name,
|
96
|
+
in: self.in,
|
97
|
+
description: description,
|
98
|
+
required: required?.presence,
|
99
|
+
allowEmptyValue: allow_empty_value?.presence,
|
100
|
+
collectionFormat: ('multi' if schema.array?)
|
101
|
+
}.merge(schema.to_openapi(version))
|
102
|
+
else
|
103
|
+
{
|
104
|
+
name: parameter_name,
|
105
|
+
in: self.in,
|
106
|
+
description: description,
|
107
|
+
required: required?.presence,
|
108
|
+
allowEmptyValue: allow_empty_value?.presence,
|
109
|
+
deprecated: deprecated?.presence,
|
110
|
+
schema: schema.to_openapi(version),
|
111
|
+
examples: examples&.transform_values(&:to_openapi)
|
112
|
+
|
113
|
+
# NOTE: collectionFormat is replaced by style and explode.
|
114
|
+
# The default values for query parameters are:
|
115
|
+
# - style: 'form'
|
116
|
+
# - explode: true
|
117
|
+
}
|
118
|
+
end
|
119
|
+
)
|
116
120
|
]
|
117
121
|
end
|
118
122
|
end
|
@@ -141,27 +145,29 @@ module Jsapi
|
|
141
145
|
description = property_schema.description
|
142
146
|
allow_empty_value = property.schema.existence <= Existence::ALLOW_EMPTY
|
143
147
|
[
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
148
|
+
with_openapi_extensions(
|
149
|
+
if version.major == 2
|
150
|
+
{
|
151
|
+
name: parameter_name,
|
152
|
+
in: self.in,
|
153
|
+
description: description,
|
154
|
+
required: required,
|
155
|
+
allowEmptyValue: allow_empty_value.presence,
|
156
|
+
collectionFormat: ('multi' if property_schema.array?)
|
157
|
+
}.merge(property_schema.to_openapi(version))
|
158
|
+
else
|
159
|
+
{
|
160
|
+
name: parameter_name,
|
161
|
+
in: self.in,
|
162
|
+
description: description,
|
163
|
+
required: required,
|
164
|
+
allowEmptyValue: allow_empty_value.presence,
|
165
|
+
deprecated: deprecated,
|
166
|
+
schema: property_schema.to_openapi(version).except(:deprecated),
|
167
|
+
examples: examples&.transform_values(&:to_openapi)
|
168
|
+
}
|
169
|
+
end
|
170
|
+
)
|
165
171
|
]
|
166
172
|
end
|
167
173
|
end
|
@@ -4,6 +4,8 @@ module Jsapi
|
|
4
4
|
module Meta
|
5
5
|
module RequestBody
|
6
6
|
class Model < Base
|
7
|
+
include OpenAPI::Extensions
|
8
|
+
|
7
9
|
##
|
8
10
|
# :attr: description
|
9
11
|
# The optional description of the request body.
|
@@ -12,7 +14,7 @@ module Jsapi
|
|
12
14
|
##
|
13
15
|
# :attr_reader: examples
|
14
16
|
# The optional examples.
|
15
|
-
attribute :examples, { String => Example }, default_key: 'default'
|
17
|
+
attribute :examples, { String => OpenAPI::Example }, default_key: 'default'
|
16
18
|
|
17
19
|
##
|
18
20
|
# :attr_reader: schema
|
@@ -44,12 +46,12 @@ module Jsapi
|
|
44
46
|
in: 'body',
|
45
47
|
description: description,
|
46
48
|
required: required?
|
47
|
-
}.merge(schema.to_openapi('2.0')).compact
|
49
|
+
}.merge(schema.to_openapi('2.0')).merge(openapi_extensions).compact
|
48
50
|
end
|
49
51
|
|
50
52
|
# Returns a hash representing the \OpenAPI 3.x request body object.
|
51
53
|
def to_openapi(version)
|
52
|
-
|
54
|
+
with_openapi_extensions(
|
53
55
|
description: description,
|
54
56
|
content: {
|
55
57
|
'application/json' => {
|
@@ -58,7 +60,7 @@ module Jsapi
|
|
58
60
|
}.compact
|
59
61
|
},
|
60
62
|
required: required?
|
61
|
-
|
63
|
+
)
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|