jsapi 1.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 +4 -4
- data/lib/jsapi/controller/methods.rb +4 -2
- data/lib/jsapi/meta/response/base.rb +8 -0
- data/lib/jsapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a24c58c515109ade6015fbd712e6d08f8ea0dc3e1b747ecd1e2430de0ad157d2
|
4
|
+
data.tar.gz: 98112b68df57d56b51f9edcaa2283069481fb0c2a494cde18cb35d0205917423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e08e06bcfe77edb6b356a0f2aa00bc141bf1aae3c1fac09fdb61be36b7be27b24a8c698fcad63374936d2defa345cbb9328f5a6f486a9816ae21be0cd52853
|
7
|
+
data.tar.gz: 8b671d32824bdb6e924fd7bd11f16c3baeac90c8bd3ef7a3796d8a8220b574740f750cad6e79f986f4950b8659ca9bb151ad95d6cfe63beb95e6ed63e76e4a3a
|
@@ -15,7 +15,7 @@ module Jsapi
|
|
15
15
|
# Performs an API operation by calling the given block. The request parameters are
|
16
16
|
# passed as an instance of the operation's model class to the block. The object
|
17
17
|
# returned by the block is implicitly rendered according to the appropriate +response+
|
18
|
-
# specification.
|
18
|
+
# specification when the content type is a JSON MIME type.
|
19
19
|
#
|
20
20
|
# api_operation('foo') do |api_params|
|
21
21
|
# # ...
|
@@ -151,9 +151,11 @@ module Jsapi
|
|
151
151
|
|
152
152
|
Error.new(e, status: status)
|
153
153
|
end
|
154
|
-
response = Response.new(result, response_model, definitions, omit: omit)
|
155
154
|
|
156
155
|
# Write response
|
156
|
+
return unless response_model.json_type?
|
157
|
+
|
158
|
+
response = Response.new(result, response_model, definitions, omit: omit)
|
157
159
|
self.content_type = response_model.content_type
|
158
160
|
render(json: response, status: status)
|
159
161
|
end
|
@@ -7,6 +7,8 @@ module Jsapi
|
|
7
7
|
class Base < Model::Base
|
8
8
|
include OpenAPI::Extensions
|
9
9
|
|
10
|
+
JSON_TYPE = %r{(^application/|^text/|\+)json$}.freeze # :nodoc:
|
11
|
+
|
10
12
|
delegate_missing_to :schema
|
11
13
|
|
12
14
|
##
|
@@ -58,6 +60,12 @@ module Jsapi
|
|
58
60
|
@schema = Schema.new(keywords)
|
59
61
|
end
|
60
62
|
|
63
|
+
# Returns true if content type is a JSON MIME type as specified by
|
64
|
+
# https://mimesniff.spec.whatwg.org/#json-mime-type.
|
65
|
+
def json_type?
|
66
|
+
content_type.match?(JSON_TYPE)
|
67
|
+
end
|
68
|
+
|
61
69
|
# Returns a hash representing the \OpenAPI response object.
|
62
70
|
def to_openapi(version, definitions)
|
63
71
|
version = OpenAPI::Version.from(version)
|
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.1'
|
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:
|
11
|
+
date: 2025-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: denis@dmgoeller.de
|