media_types-serialization 2.0.0 → 2.1.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/.github/workflows/ci.yml +1 -1
- data/.github/workflows/publish-bookworm.yml +4 -3
- data/.github/workflows/publish-sid.yml +4 -3
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +176 -0
- data/README.md +10 -0
- data/lib/media_types/serialization/fake_validator.rb +1 -1
- data/lib/media_types/serialization/serialization_dsl.rb +4 -0
- data/lib/media_types/serialization/serializers/endpoint_description_serializer.rb +21 -21
- data/lib/media_types/serialization/serializers/input_validation_error_serializer.rb +7 -5
- data/lib/media_types/serialization/serializers/problem_serializer.rb +1 -1
- data/lib/media_types/serialization/version.rb +1 -1
- data/lib/media_types/serialization.rb +13 -6
- data/media_types-serialization.gemspec +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d19f8ce2e2010426e6fe53e7a0113c3ccc2fd38c7446a96a1310dcf8fea6440
|
4
|
+
data.tar.gz: ad053ac0885c6ac7349f1efe530253089e93e1da26547af82bd990a98215120e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df08264d2b33ebcf0c556d4a3a4b51b6695763ae5d932424140f805b42d4eccabccf6002e2529d7b62107cfe186ae338f5ccba32ffbc5d3a5eabe47318f534f9
|
7
|
+
data.tar.gz: acce1b9414c5c9d478113b4597441ea08f9936ed0cdfc2dcacded8abc055fde2a8ea6a43655db27c74757ea41d16c5319be176702b42701dd5902d98cf862cf7
|
data/.github/workflows/ci.yml
CHANGED
@@ -9,14 +9,15 @@ jobs:
|
|
9
9
|
container:
|
10
10
|
image: debian:bookworm
|
11
11
|
steps:
|
12
|
-
- uses: actions/checkout@v3
|
13
|
-
name: Check out repository
|
14
12
|
- name: Install repo
|
15
13
|
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install wget && wget -O key.deb https://deb1.ws.maxmaton.nl/key.deb && DEBIAN_FRONTEND=noninteractive apt-get --yes install ./key.deb && echo "deb [signed-by=/usr/share/keyrings/maxmaton.gpg] http://deb.maxmaton.nl/debian bookworm main non-free" > /etc/apt/sources.list.d/maxmaton.list
|
16
14
|
- name: Install dependencies
|
17
|
-
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install build-essential gem scrypt sshpass gem2deb ruby-actionpack ruby-activesupport ruby-media-types
|
15
|
+
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install git build-essential gem scrypt sshpass gem2deb ruby-actionpack ruby-activesupport ruby-media-types
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
name: Check out repository
|
18
18
|
- name: Build gem
|
19
19
|
run: |
|
20
|
+
git config --global --add safe.directory "$(pwd)"
|
20
21
|
sed -i -re "s/VERSION\s+=\s+'([0-9]+.[0-9]+.[0-9]+)'/VERSION = '\1.bookworm'/g" lib/media_types/serialization/version.rb
|
21
22
|
gem build media_types-serialization.gemspec
|
22
23
|
- name: Build deb
|
@@ -9,14 +9,15 @@ jobs:
|
|
9
9
|
container:
|
10
10
|
image: debian:sid
|
11
11
|
steps:
|
12
|
-
- uses: actions/checkout@v3
|
13
|
-
name: Check out repository
|
14
12
|
- name: Install repo
|
15
13
|
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install wget && wget -O key.deb https://deb1.ws.maxmaton.nl/key.deb && DEBIAN_FRONTEND=noninteractive apt-get --yes install ./key.deb && echo "deb [signed-by=/usr/share/keyrings/maxmaton.gpg] http://deb.maxmaton.nl/debian sid main non-free" > /etc/apt/sources.list.d/maxmaton.list
|
16
14
|
- name: Install dependencies
|
17
|
-
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install build-essential gem scrypt sshpass gem2deb ruby-actionpack ruby-activesupport ruby-media-types
|
15
|
+
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get --yes install git build-essential gem scrypt sshpass gem2deb ruby-actionpack ruby-activesupport ruby-media-types
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
name: Check out repository
|
18
18
|
- name: Build gem
|
19
19
|
run: |
|
20
|
+
git config --global --add safe.directory "$(pwd)"
|
20
21
|
sed -i -re "s/VERSION\s+=\s+'([0-9]+.[0-9]+.[0-9]+)'/VERSION = '\1.sid'/g" lib/media_types/serialization/version.rb
|
21
22
|
gem build media_types-serialization.gemspec
|
22
23
|
- name: Build deb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
|
5
|
+
- ✨ Add `varies_on_header` serializer dsl function.
|
6
|
+
- 🐛 Fix [crash in input validation error serializer](https://github.com/XPBytes/media_types-serialization/issues/260)
|
7
|
+
- 🐛 Fix [endpoint description having media types multiple times](https://github.com/XPBytes/media_types-serialization/issues/184)
|
8
|
+
- 🐛 Fix problem serializer not Varying on Accept-Language
|
9
|
+
|
10
|
+
## 2.0.4
|
11
|
+
|
12
|
+
- ✨ Add more loose tests
|
13
|
+
- 🐛 Fix `locals` passing for HTML serialization
|
14
|
+
- 🐛 Fix for status passing in rack-like environments
|
15
|
+
|
16
|
+
## 2.0.3
|
17
|
+
|
18
|
+
- 🐛 Fix debian packages not containing files
|
19
|
+
|
3
20
|
## 2.0.0
|
4
21
|
|
5
22
|
- ✨ Add support for loose input validation
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
media_types-serialization (2.1.0)
|
5
|
+
actionpack (>= 6.0.0)
|
6
|
+
activesupport (>= 6.0.0)
|
7
|
+
media_types (>= 2.2.3, < 3.0.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actioncable (6.1.7.8)
|
13
|
+
actionpack (= 6.1.7.8)
|
14
|
+
activesupport (= 6.1.7.8)
|
15
|
+
nio4r (~> 2.0)
|
16
|
+
websocket-driver (>= 0.6.1)
|
17
|
+
actionmailbox (6.1.7.8)
|
18
|
+
actionpack (= 6.1.7.8)
|
19
|
+
activejob (= 6.1.7.8)
|
20
|
+
activerecord (= 6.1.7.8)
|
21
|
+
activestorage (= 6.1.7.8)
|
22
|
+
activesupport (= 6.1.7.8)
|
23
|
+
mail (>= 2.7.1)
|
24
|
+
actionmailer (6.1.7.8)
|
25
|
+
actionpack (= 6.1.7.8)
|
26
|
+
actionview (= 6.1.7.8)
|
27
|
+
activejob (= 6.1.7.8)
|
28
|
+
activesupport (= 6.1.7.8)
|
29
|
+
mail (~> 2.5, >= 2.5.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
actionpack (6.1.7.8)
|
32
|
+
actionview (= 6.1.7.8)
|
33
|
+
activesupport (= 6.1.7.8)
|
34
|
+
rack (~> 2.0, >= 2.0.9)
|
35
|
+
rack-test (>= 0.6.3)
|
36
|
+
rails-dom-testing (~> 2.0)
|
37
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
38
|
+
actiontext (6.1.7.8)
|
39
|
+
actionpack (= 6.1.7.8)
|
40
|
+
activerecord (= 6.1.7.8)
|
41
|
+
activestorage (= 6.1.7.8)
|
42
|
+
activesupport (= 6.1.7.8)
|
43
|
+
nokogiri (>= 1.8.5)
|
44
|
+
actionview (6.1.7.8)
|
45
|
+
activesupport (= 6.1.7.8)
|
46
|
+
builder (~> 3.1)
|
47
|
+
erubi (~> 1.4)
|
48
|
+
rails-dom-testing (~> 2.0)
|
49
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
50
|
+
activejob (6.1.7.8)
|
51
|
+
activesupport (= 6.1.7.8)
|
52
|
+
globalid (>= 0.3.6)
|
53
|
+
activemodel (6.1.7.8)
|
54
|
+
activesupport (= 6.1.7.8)
|
55
|
+
activerecord (6.1.7.8)
|
56
|
+
activemodel (= 6.1.7.8)
|
57
|
+
activesupport (= 6.1.7.8)
|
58
|
+
activestorage (6.1.7.8)
|
59
|
+
actionpack (= 6.1.7.8)
|
60
|
+
activejob (= 6.1.7.8)
|
61
|
+
activerecord (= 6.1.7.8)
|
62
|
+
activesupport (= 6.1.7.8)
|
63
|
+
marcel (~> 1.0)
|
64
|
+
mini_mime (>= 1.1.0)
|
65
|
+
activesupport (6.1.7.8)
|
66
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
67
|
+
i18n (>= 1.6, < 2)
|
68
|
+
minitest (>= 5.1)
|
69
|
+
tzinfo (~> 2.0)
|
70
|
+
zeitwerk (~> 2.3)
|
71
|
+
awesome_print (1.9.2)
|
72
|
+
bigdecimal (3.1.8)
|
73
|
+
builder (3.3.0)
|
74
|
+
concurrent-ruby (1.3.4)
|
75
|
+
crass (1.0.6)
|
76
|
+
date (3.3.4)
|
77
|
+
erubi (1.13.0)
|
78
|
+
globalid (1.2.1)
|
79
|
+
activesupport (>= 6.1)
|
80
|
+
i18n (1.14.5)
|
81
|
+
concurrent-ruby (~> 1.0)
|
82
|
+
loofah (2.22.0)
|
83
|
+
crass (~> 1.0.2)
|
84
|
+
nokogiri (>= 1.12.0)
|
85
|
+
mail (2.8.1)
|
86
|
+
mini_mime (>= 0.1.1)
|
87
|
+
net-imap
|
88
|
+
net-pop
|
89
|
+
net-smtp
|
90
|
+
marcel (1.0.4)
|
91
|
+
media_types (2.3.3.bookworm)
|
92
|
+
method_source (1.1.0)
|
93
|
+
mini_mime (1.1.5)
|
94
|
+
minitest (5.25.1)
|
95
|
+
net-imap (0.4.14)
|
96
|
+
date
|
97
|
+
net-protocol
|
98
|
+
net-pop (0.1.2)
|
99
|
+
net-protocol
|
100
|
+
net-protocol (0.2.2)
|
101
|
+
timeout
|
102
|
+
net-smtp (0.5.0)
|
103
|
+
net-protocol
|
104
|
+
nio4r (2.7.3)
|
105
|
+
nokogiri (1.16.7-x64-mingw32)
|
106
|
+
racc (~> 1.4)
|
107
|
+
nokogiri (1.16.7-x86_64-linux)
|
108
|
+
racc (~> 1.4)
|
109
|
+
oj (3.16.7)
|
110
|
+
bigdecimal (>= 3.0)
|
111
|
+
ostruct (>= 0.2)
|
112
|
+
ostruct (0.6.0)
|
113
|
+
racc (1.8.1)
|
114
|
+
rack (2.2.9)
|
115
|
+
rack-test (2.1.0)
|
116
|
+
rack (>= 1.3)
|
117
|
+
rails (6.1.7.8)
|
118
|
+
actioncable (= 6.1.7.8)
|
119
|
+
actionmailbox (= 6.1.7.8)
|
120
|
+
actionmailer (= 6.1.7.8)
|
121
|
+
actionpack (= 6.1.7.8)
|
122
|
+
actiontext (= 6.1.7.8)
|
123
|
+
actionview (= 6.1.7.8)
|
124
|
+
activejob (= 6.1.7.8)
|
125
|
+
activemodel (= 6.1.7.8)
|
126
|
+
activerecord (= 6.1.7.8)
|
127
|
+
activestorage (= 6.1.7.8)
|
128
|
+
activesupport (= 6.1.7.8)
|
129
|
+
bundler (>= 1.15.0)
|
130
|
+
railties (= 6.1.7.8)
|
131
|
+
sprockets-rails (>= 2.0.0)
|
132
|
+
rails-dom-testing (2.2.0)
|
133
|
+
activesupport (>= 5.0.0)
|
134
|
+
minitest
|
135
|
+
nokogiri (>= 1.6)
|
136
|
+
rails-html-sanitizer (1.6.0)
|
137
|
+
loofah (~> 2.21)
|
138
|
+
nokogiri (~> 1.14)
|
139
|
+
railties (6.1.7.8)
|
140
|
+
actionpack (= 6.1.7.8)
|
141
|
+
activesupport (= 6.1.7.8)
|
142
|
+
method_source
|
143
|
+
rake (>= 12.2)
|
144
|
+
thor (~> 1.0)
|
145
|
+
rake (13.2.1)
|
146
|
+
sprockets (4.2.1)
|
147
|
+
concurrent-ruby (~> 1.0)
|
148
|
+
rack (>= 2.2.4, < 4)
|
149
|
+
sprockets-rails (3.5.2)
|
150
|
+
actionpack (>= 6.1)
|
151
|
+
activesupport (>= 6.1)
|
152
|
+
sprockets (>= 3.0.0)
|
153
|
+
thor (1.3.1)
|
154
|
+
timeout (0.4.1)
|
155
|
+
tzinfo (2.0.6)
|
156
|
+
concurrent-ruby (~> 1.0)
|
157
|
+
websocket-driver (0.7.6)
|
158
|
+
websocket-extensions (>= 0.1.0)
|
159
|
+
websocket-extensions (0.1.5)
|
160
|
+
zeitwerk (2.6.17)
|
161
|
+
|
162
|
+
PLATFORMS
|
163
|
+
x64-mingw32
|
164
|
+
x86_64-linux
|
165
|
+
|
166
|
+
DEPENDENCIES
|
167
|
+
awesome_print
|
168
|
+
bundler
|
169
|
+
media_types-serialization!
|
170
|
+
minitest (~> 5.0)
|
171
|
+
oj
|
172
|
+
rails (~> 6.0)
|
173
|
+
rake (~> 13.0)
|
174
|
+
|
175
|
+
BUNDLED WITH
|
176
|
+
2.3.15
|
data/README.md
CHANGED
@@ -897,6 +897,16 @@ This redirects the user to the specified url when this serializer is rendered. T
|
|
897
897
|
|
898
898
|
Replaces the render at the end of `render_media` and substitutes it with the contents of the block.
|
899
899
|
|
900
|
+
#### `varies_on_header(header)`
|
901
|
+
|
902
|
+
Indicates to clients that they can receive a different response if the indicated header has a different value. This is done using the [Vary header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Vary). When your responses are internationalized you can use the following example:
|
903
|
+
|
904
|
+
```ruby
|
905
|
+
varies_on_header 'Accept-Language'
|
906
|
+
```
|
907
|
+
|
908
|
+
The Vary header is set at two moments during execution. The first moment the header is modified is during the `freeze_io!` handler. The second moment is when `render_media` is called. If you want to modify the Vary header that is returned when the content negotiation fails you need to make sure to run your callback before the `freeze_io!` callback has been run.
|
909
|
+
|
900
910
|
### Controller definition
|
901
911
|
|
902
912
|
These functions are available during the controller definition if you add `include MediaTypes::Serialization`.
|
@@ -114,6 +114,10 @@ module MediaTypes
|
|
114
114
|
context.serialization_dsl_result
|
115
115
|
end
|
116
116
|
|
117
|
+
def varies_on_header(header)
|
118
|
+
@serialization_vary.push(header) unless @serialization_vary.include? header
|
119
|
+
end
|
120
|
+
|
117
121
|
def redirect_to(url, context, **options)
|
118
122
|
suppress_render do |result|
|
119
123
|
context.redirect_to(
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'media_types/serialization/base'
|
@@ -7,41 +6,43 @@ module MediaTypes
|
|
7
6
|
module Serialization
|
8
7
|
module Serializers
|
9
8
|
class EndpointDescriptionSerializer < MediaTypes::Serialization::Base
|
10
|
-
|
11
9
|
unvalidated 'application/vnd.delftsolutions.endpoint_description'
|
12
10
|
|
13
11
|
disable_wildcards
|
14
12
|
|
15
13
|
def self.to_input_identifiers(serializers)
|
16
|
-
serializers
|
17
|
-
|
18
|
-
|
14
|
+
serializers
|
15
|
+
.flat_map do |s|
|
16
|
+
s[:serializer].inputs_for(views: [s[:view]]).registrations.keys
|
17
|
+
end
|
18
|
+
.uniq
|
19
19
|
end
|
20
|
+
|
20
21
|
def self.to_output_identifiers(serializers)
|
21
|
-
serializers
|
22
|
-
|
23
|
-
|
22
|
+
serializers
|
23
|
+
.flat_map do |s|
|
24
|
+
s[:serializer].outputs_for(views: [s[:view]]).registrations.keys
|
25
|
+
end
|
26
|
+
.uniq
|
24
27
|
end
|
25
28
|
|
26
|
-
output version: 1 do |input,
|
29
|
+
output version: 1 do |input, _version, context|
|
27
30
|
request_path = context.request.original_fullpath.split('?')[0]
|
28
31
|
|
29
|
-
path_prefix = ENV.fetch('RAILS_RELATIVE_URL_ROOT'
|
32
|
+
path_prefix = ENV.fetch('RAILS_RELATIVE_URL_ROOT', '')
|
30
33
|
request_path = request_path.sub(path_prefix, '')
|
31
34
|
|
32
35
|
my_controller = Rails.application.routes.recognize_path request_path
|
33
36
|
|
34
37
|
methods_available = {}
|
35
|
-
methods = [
|
38
|
+
methods = %w[GET POST PUT PATCH DELETE]
|
36
39
|
methods.each do |m|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
methods_available[m] = found_controller[:action]
|
41
|
-
end
|
42
|
-
rescue ActionController::RoutingError
|
43
|
-
# not available
|
40
|
+
found_controller = Rails.application.routes.recognize_path request_path, method: m
|
41
|
+
if found_controller[:controller] == my_controller[:controller]
|
42
|
+
methods_available[m] = found_controller[:action]
|
44
43
|
end
|
44
|
+
rescue ActionController::RoutingError
|
45
|
+
# not available
|
45
46
|
end
|
46
47
|
|
47
48
|
input_definitions = input[:actions][:input] || {}
|
@@ -55,8 +56,8 @@ module MediaTypes
|
|
55
56
|
|
56
57
|
viewer_uri = URI.parse(context.request.original_url)
|
57
58
|
query_parts = viewer_uri.query&.split('&') || []
|
58
|
-
query_parts = query_parts.
|
59
|
-
viewer_uri.query = (query_parts + [
|
59
|
+
query_parts = query_parts.reject { |q| q.start_with? 'api_viewer=' }
|
60
|
+
viewer_uri.query = (query_parts + ['api_viewer=last']).join('&')
|
60
61
|
|
61
62
|
methods_available.each do |method, action|
|
62
63
|
has_viewer = viewer_definitions[action] || global_viewer
|
@@ -73,7 +74,6 @@ module MediaTypes
|
|
73
74
|
|
74
75
|
result
|
75
76
|
end
|
76
|
-
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -10,8 +10,8 @@ module MediaTypes
|
|
10
10
|
class InputValidationErrorSerializer < MediaTypes::Serialization::Base
|
11
11
|
unvalidated 'text/html'
|
12
12
|
|
13
|
-
def self.escape_text(text)
|
14
|
-
text
|
13
|
+
def self.escape_text(text, context)
|
14
|
+
result = text
|
15
15
|
.split("\n")
|
16
16
|
.map { |l| CGI.escapeHTML(l).gsub(/ (?= )/, ' ') }
|
17
17
|
.map do |l|
|
@@ -19,7 +19,7 @@ module MediaTypes
|
|
19
19
|
converted = m
|
20
20
|
invalid = false
|
21
21
|
begin
|
22
|
-
converted = viewerify(m, context.request.host)
|
22
|
+
converted = ApiViewer.viewerify(m, context.request.host)
|
23
23
|
rescue URI::InvalidURIError
|
24
24
|
invalid = true
|
25
25
|
end
|
@@ -29,6 +29,8 @@ module MediaTypes
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
.join("<br>\n")
|
32
|
+
result.html_safe
|
33
|
+
result
|
32
34
|
end
|
33
35
|
|
34
36
|
output_raw do |obj, version, context|
|
@@ -36,8 +38,8 @@ module MediaTypes
|
|
36
38
|
original_input = obj[:input]
|
37
39
|
error = obj[:error]
|
38
40
|
|
39
|
-
escaped_error = escape_text(error.message)
|
40
|
-
escaped_input = escape_text(original_input)
|
41
|
+
escaped_error = escape_text(error.message, context)
|
42
|
+
escaped_input = escape_text(original_input, context)
|
41
43
|
|
42
44
|
input = OpenStruct.new(
|
43
45
|
original_identifier: input_identifier,
|
@@ -8,13 +8,13 @@ module MediaTypes
|
|
8
8
|
module Serialization
|
9
9
|
module Serializers
|
10
10
|
class ProblemSerializer < MediaTypes::Serialization::Base
|
11
|
-
|
12
11
|
unvalidated 'application/vnd.delftsolutions.problem'
|
13
12
|
disable_wildcards
|
14
13
|
|
15
14
|
output do |problem, _, context|
|
16
15
|
raise 'No translations defined, add at least one title' unless problem.translations.keys.any?
|
17
16
|
|
17
|
+
varies_on_header 'Accept-Language'
|
18
18
|
accept_language_header = Utils::AcceptLanguageHeader.new(
|
19
19
|
context.request.get_header(HEADER_ACCEPT_LANGUAGE) || ''
|
20
20
|
)
|
@@ -201,7 +201,7 @@ module MediaTypes
|
|
201
201
|
options[:template] = view unless view.nil?
|
202
202
|
options[:formats] = formats unless formats.nil?
|
203
203
|
options[:variants] = variants unless variants.nil?
|
204
|
-
options[:locals] = victim if victim.is_a?(Hash)
|
204
|
+
options[:locals] = victim if victim.is_a?(::Hash)
|
205
205
|
options[:assigns] = { media: victim }
|
206
206
|
|
207
207
|
controller.render_to_string(**options)
|
@@ -448,7 +448,7 @@ module MediaTypes
|
|
448
448
|
end
|
449
449
|
|
450
450
|
return @serialization_override_accept if registration.has? @serialization_override_accept
|
451
|
-
|
451
|
+
|
452
452
|
# Always render problems in api viewer if we can't show chosen override
|
453
453
|
return 'application/problem+json' if registration.has? 'application/problem+json'
|
454
454
|
|
@@ -541,10 +541,14 @@ module MediaTypes
|
|
541
541
|
self
|
542
542
|
)
|
543
543
|
rescue InputValidationFailedError => e
|
544
|
-
serializers = @serialization_input_validation_failed_serializer
|
545
|
-
|
546
|
-
|
547
|
-
|
544
|
+
serializers = if defined?(@serialization_input_validation_failed_serializer)
|
545
|
+
@serialization_input_validation_failed_serializer
|
546
|
+
else
|
547
|
+
[
|
548
|
+
MediaTypes::Serialization::Serializers::ProblemSerializer,
|
549
|
+
MediaTypes::Serialization::Serializers::InputValidationErrorSerializer
|
550
|
+
]
|
551
|
+
end
|
548
552
|
registrations = SerializationRegistration.new(:output)
|
549
553
|
serializers.each do |s|
|
550
554
|
registrations = registrations.merge(s.outputs_for(views: [nil, :html]))
|
@@ -671,6 +675,9 @@ module MediaTypes
|
|
671
675
|
end
|
672
676
|
|
673
677
|
if context.serialization_custom_render.nil?
|
678
|
+
status = options.delete(:status)
|
679
|
+
response.status = status if status
|
680
|
+
|
674
681
|
render body: result, **options
|
675
682
|
|
676
683
|
response.content_type = registrations.identifier_for(identifier)
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
|
38
38
|
spec.add_dependency 'actionpack', '>= 6.0.0'
|
39
39
|
spec.add_dependency 'activesupport', '>= 6.0.0'
|
40
|
-
spec.add_dependency 'media_types', '>= 2.2.
|
40
|
+
spec.add_dependency 'media_types', '>= 2.2.3', '< 3.0.0'
|
41
41
|
|
42
42
|
spec.add_development_dependency 'awesome_print'
|
43
43
|
spec.add_development_dependency 'bundler'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: media_types-serialization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derk-Jan Karrenbeld
|
8
8
|
- Max Maton
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.2.
|
48
|
+
version: 2.2.3
|
49
49
|
- - "<"
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: 3.0.0
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: 2.2.
|
58
|
+
version: 2.2.3
|
59
59
|
- - "<"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.0.0
|
@@ -143,7 +143,7 @@ dependencies:
|
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
|
-
description:
|
146
|
+
description:
|
147
147
|
email:
|
148
148
|
- derk-jan@xpbytes.com
|
149
149
|
- max@delftsolutions.nl
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- CHANGELOG.md
|
169
169
|
- CODE_OF_CONDUCT.md
|
170
170
|
- Gemfile
|
171
|
+
- Gemfile.lock
|
171
172
|
- LICENSE.txt
|
172
173
|
- README.md
|
173
174
|
- Rakefile
|
@@ -199,7 +200,7 @@ metadata:
|
|
199
200
|
homepage_uri: https://github.com/XPBytes/media_types-serialization
|
200
201
|
source_code_uri: https://github.com/XPBytes/media_types-serialization
|
201
202
|
changelog_uri: https://github.com/XPBytes/media_types-serialization/blob/master/CHANGELOG.md
|
202
|
-
post_install_message:
|
203
|
+
post_install_message:
|
203
204
|
rdoc_options: []
|
204
205
|
require_paths:
|
205
206
|
- lib
|
@@ -214,8 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
215
|
- !ruby/object:Gem::Version
|
215
216
|
version: '0'
|
216
217
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
218
|
-
signing_key:
|
218
|
+
rubygems_version: 3.3.15
|
219
|
+
signing_key:
|
219
220
|
specification_version: 4
|
220
221
|
summary: Add media types supported serialization using your favourite serializer
|
221
222
|
test_files: []
|