media_types-serialization 0.8.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +16 -3
  3. data/.prettierrc +1 -0
  4. data/CHANGELOG.md +42 -0
  5. data/CODE_OF_CONDUCT.md +74 -74
  6. data/Gemfile.lock +74 -83
  7. data/README.md +691 -179
  8. data/lib/media_types/problem.rb +64 -0
  9. data/lib/media_types/serialization.rb +497 -173
  10. data/lib/media_types/serialization/base.rb +115 -91
  11. data/lib/media_types/serialization/error.rb +186 -0
  12. data/lib/media_types/serialization/fake_validator.rb +52 -0
  13. data/lib/media_types/serialization/serialization_dsl.rb +117 -0
  14. data/lib/media_types/serialization/serialization_registration.rb +245 -0
  15. data/lib/media_types/serialization/serializers/api_viewer.rb +133 -0
  16. data/lib/media_types/serialization/serializers/common_css.rb +168 -0
  17. data/lib/media_types/serialization/serializers/endpoint_description_serializer.rb +80 -0
  18. data/lib/media_types/serialization/serializers/fallback_not_acceptable_serializer.rb +85 -0
  19. data/lib/media_types/serialization/serializers/fallback_unsupported_media_type_serializer.rb +58 -0
  20. data/lib/media_types/serialization/serializers/input_validation_error_serializer.rb +89 -0
  21. data/lib/media_types/serialization/serializers/problem_serializer.rb +100 -0
  22. data/lib/media_types/serialization/utils/accept_header.rb +77 -0
  23. data/lib/media_types/serialization/utils/accept_language_header.rb +82 -0
  24. data/lib/media_types/serialization/utils/header_list.rb +89 -0
  25. data/lib/media_types/serialization/version.rb +1 -1
  26. data/media_types-serialization.gemspec +48 -50
  27. metadata +48 -79
  28. data/.travis.yml +0 -17
  29. data/lib/generators/media_types/serialization/api_viewer/api_viewer_generator.rb +0 -25
  30. data/lib/generators/media_types/serialization/api_viewer/templates/api_viewer.html.erb +0 -98
  31. data/lib/generators/media_types/serialization/api_viewer/templates/initializer.rb +0 -33
  32. data/lib/generators/media_types/serialization/api_viewer/templates/template_controller.rb +0 -23
  33. data/lib/media_types/serialization/media_type/register.rb +0 -4
  34. data/lib/media_types/serialization/migrations_command.rb +0 -38
  35. data/lib/media_types/serialization/migrations_support.rb +0 -50
  36. data/lib/media_types/serialization/mime_type_support.rb +0 -64
  37. data/lib/media_types/serialization/no_content_type_given.rb +0 -11
  38. data/lib/media_types/serialization/no_media_type_serializers.rb +0 -11
  39. data/lib/media_types/serialization/no_serializer_for_content_type.rb +0 -15
  40. data/lib/media_types/serialization/renderer.rb +0 -41
  41. data/lib/media_types/serialization/renderer/register.rb +0 -4
  42. data/lib/media_types/serialization/wrapper.rb +0 -13
  43. data/lib/media_types/serialization/wrapper/html_wrapper.rb +0 -45
  44. data/lib/media_types/serialization/wrapper/media_collection_wrapper.rb +0 -59
  45. data/lib/media_types/serialization/wrapper/media_index_wrapper.rb +0 -59
  46. data/lib/media_types/serialization/wrapper/media_object_wrapper.rb +0 -55
  47. data/lib/media_types/serialization/wrapper_support.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2041c208e2369bfd60399c0dce92cbea8f3e0c51c1c4b361c6c29540285eb95a
4
- data.tar.gz: 7cae4d020bc3c1b79665dc4cccb36701ed360190995f57c56eee7c0e715ce6e0
3
+ metadata.gz: f7eabad722268eb76ce511245770ef7fb6a4c07c9d0ce8be05ac0995a4ebe309
4
+ data.tar.gz: f749dfcbc363662ddb7e7a2d81162168fa1dea8bb086aa57074d1a51d3bfc5c5
5
5
  SHA512:
6
- metadata.gz: 763a81b77ce760ad2634b4b8670286105ce017f205f9a1fc2b92d2f018af1512a15179bea3899f39c580c5b79207955e6dc869377eca1cf431c24bff7c410d74
7
- data.tar.gz: f255ce45bf62686fa789d309061030f23445fdbd68854cd7a9204c6e7ae4df701c8d7308b9b153e8ba95cd0287b44d0c9200c0d8df95869fc1329913f110d718
6
+ metadata.gz: e64bafc043adbb81c87475e2898687f1495b7e15f8bb71dbb73fe2a0ea9f39556d4644f60f3f6658d196efe533f8cf8a504b7b8936e7812dc607bce628f400e4
7
+ data.tar.gz: e4aa0a59bc0e3a8f785feda5d99b15a5f193984b3fd6deb5b06577e90b0c8628f615c7214258c0d08383bd5fc171a7249d8985a14d0fadc4f32734899981572a
@@ -1,18 +1,31 @@
1
1
  name: Ruby
2
2
 
3
- on: [push]
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ push:
8
+ branches:
9
+ - master
10
+ - depfu/*
11
+ - release/*
12
+ - feature/*
4
13
 
5
14
  jobs:
6
15
  build:
7
16
 
8
17
  runs-on: ubuntu-latest
9
18
 
19
+ strategy:
20
+ matrix:
21
+ ruby-version: [2.7.x, 2.6.x]
22
+
10
23
  steps:
11
24
  - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
25
+ - name: Set up Ruby ${{ matrix.ruby-version }}
13
26
  uses: actions/setup-ruby@v1
14
27
  with:
15
- ruby-version: 2.6.x
28
+ ruby-version: ${{ matrix.ruby-version }}
16
29
  - name: Build and test with Rake
17
30
  run: |
18
31
  gem install bundler
data/.prettierrc ADDED
@@ -0,0 +1 @@
1
+ {}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - ✨ Add _allow_output_html_: Fallback to rails rendering.
6
+ - ✨ Add _allow_output_docs_: Useful to add a documentation description to endpoints that you can normally only POST to.
7
+ - ✨ Add _output_error_: Implements missing content-language support.
8
+ - ✨ Add _scoped freeze_io! support_: Useful for gradual adoption of mediatypes on existing routes.
9
+ - ✨ Add _alias variant reporting_: Allows reporting what the original matched media type was even when impersonating a different media type.
10
+ - ✨ Improve README: small improvements to make it easier to adopt and upgrade existing codebase.
11
+ - ✨ Reduce number of (external) dependencies
12
+ - 🐛 Fix incorrect output on encoding errors.
13
+ - 🐛 Fix message in various alias error messages.
14
+
15
+ ## 1.0.3
16
+
17
+ - 🐛 Unvalidated serializers would put the view part of the identifier before the version. This was not in line with validated serializers.
18
+
19
+ ## 1.0.2
20
+
21
+ - 🐛 Explicitly set all oj parameters when decoding as well.
22
+
23
+ ## 1.0.1
24
+
25
+ - 🐛 Explicitly set all oj and json parameters to ensure correct behavior with changed defaults.
26
+ - 🐛 Fix serializer not deserializing as symbols.
27
+
28
+ ## 1.0.0
29
+
30
+ - ✨ Add support for input deserialization.
31
+ - ✨ Add serializer DSL to be more in line with validation gem.
32
+ - ✨ Add ability to make a serializer without a validator.
33
+ - ✨ Add error serializer that emits [`application/problem+json`](https://tools.ietf.org/html/rfc7231).
34
+ - ✨ Reduce number of dependencies.
35
+ - ✨ Validators no longer need to be registered to be used.
36
+ - ✨ Add a [wiki where errors can be documented](https://docs.delftsolutions.nl). Feel free to make pages for your own namespaced errors.
37
+ - 💔 Serializer definition API has backwards incompatible changes.
38
+ - 💔 API viewer is now no longer registered as html but accessible with the `?api_viewer=last` query parameter.
39
+ - 💔 Validators can no longer be registered for use in `format do`.
40
+
41
+ ## 0.8.1
42
+
43
+ - 🐛 Fix collection wrappers sometimes sending the wrong data to serializers
44
+
3
45
  ## 0.8.0
4
46
 
5
47
  - ✨ Add support for having multiple link headers with the same `rel`
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,74 +1,74 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at derk-jan+github@karrenbeld.info. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at derk-jan+github@karrenbeld.info. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile.lock CHANGED
@@ -1,146 +1,137 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- media_types-serialization (0.7.0)
4
+ media_types-serialization (1.0.3)
5
5
  actionpack (>= 4.0.0)
6
6
  activesupport (>= 4.0.0)
7
- http_headers-accept (>= 0.2.2, < 1.0.0)
8
- http_headers-link (< 1.0.0)
9
- media_types (>= 0.6.2)
10
- oj (>= 3.5.0)
7
+ media_types (>= 2.0.0, < 3.0.0)
11
8
 
12
9
  GEM
13
10
  remote: https://rubygems.org/
14
11
  specs:
15
- actioncable (5.2.2)
16
- actionpack (= 5.2.2)
12
+ actioncable (5.2.6)
13
+ actionpack (= 5.2.6)
17
14
  nio4r (~> 2.0)
18
15
  websocket-driver (>= 0.6.1)
19
- actionmailer (5.2.2)
20
- actionpack (= 5.2.2)
21
- actionview (= 5.2.2)
22
- activejob (= 5.2.2)
16
+ actionmailer (5.2.6)
17
+ actionpack (= 5.2.6)
18
+ actionview (= 5.2.6)
19
+ activejob (= 5.2.6)
23
20
  mail (~> 2.5, >= 2.5.4)
24
21
  rails-dom-testing (~> 2.0)
25
- actionpack (5.2.2)
26
- actionview (= 5.2.2)
27
- activesupport (= 5.2.2)
28
- rack (~> 2.0)
22
+ actionpack (5.2.6)
23
+ actionview (= 5.2.6)
24
+ activesupport (= 5.2.6)
25
+ rack (~> 2.0, >= 2.0.8)
29
26
  rack-test (>= 0.6.3)
30
27
  rails-dom-testing (~> 2.0)
31
28
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
- actionview (5.2.2)
33
- activesupport (= 5.2.2)
29
+ actionview (5.2.6)
30
+ activesupport (= 5.2.6)
34
31
  builder (~> 3.1)
35
32
  erubi (~> 1.4)
36
33
  rails-dom-testing (~> 2.0)
37
34
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
38
- activejob (5.2.2)
39
- activesupport (= 5.2.2)
35
+ activejob (5.2.6)
36
+ activesupport (= 5.2.6)
40
37
  globalid (>= 0.3.6)
41
- activemodel (5.2.2)
42
- activesupport (= 5.2.2)
43
- activerecord (5.2.2)
44
- activemodel (= 5.2.2)
45
- activesupport (= 5.2.2)
38
+ activemodel (5.2.6)
39
+ activesupport (= 5.2.6)
40
+ activerecord (5.2.6)
41
+ activemodel (= 5.2.6)
42
+ activesupport (= 5.2.6)
46
43
  arel (>= 9.0)
47
- activestorage (5.2.2)
48
- actionpack (= 5.2.2)
49
- activerecord (= 5.2.2)
50
- marcel (~> 0.3.1)
51
- activesupport (5.2.2)
44
+ activestorage (5.2.6)
45
+ actionpack (= 5.2.6)
46
+ activerecord (= 5.2.6)
47
+ marcel (~> 1.0.0)
48
+ activesupport (5.2.6)
52
49
  concurrent-ruby (~> 1.0, >= 1.0.2)
53
50
  i18n (>= 0.7, < 2)
54
51
  minitest (~> 5.1)
55
52
  tzinfo (~> 1.1)
56
53
  arel (9.0.0)
57
- awesome_print (1.8.0)
58
- builder (3.2.3)
59
- concurrent-ruby (1.1.4)
60
- crass (1.0.5)
61
- erubi (1.8.0)
54
+ awesome_print (1.9.2)
55
+ builder (3.2.4)
56
+ concurrent-ruby (1.1.9)
57
+ crass (1.0.6)
58
+ erubi (1.10.0)
62
59
  globalid (0.4.2)
63
60
  activesupport (>= 4.2.0)
64
- http_headers-accept (0.2.2)
65
- http_headers-utils (>= 0.2.0, < 1.0.0)
66
- http_headers-link (0.2.1)
67
- http_headers-utils (>= 0.2.0, < 1.0.0)
68
- http_headers-utils (0.2.0)
69
- i18n (1.6.0)
61
+ i18n (1.8.10)
70
62
  concurrent-ruby (~> 1.0)
71
- loofah (2.3.1)
63
+ loofah (2.10.0)
72
64
  crass (~> 1.0.2)
73
65
  nokogiri (>= 1.5.9)
74
66
  mail (2.7.1)
75
67
  mini_mime (>= 0.1.1)
76
- marcel (0.3.3)
77
- mimemagic (~> 0.3.2)
78
- media_types (0.6.2)
79
- method_source (0.9.2)
80
- mimemagic (0.3.3)
81
- mini_mime (1.0.1)
82
- mini_portile2 (2.4.0)
83
- minitest (5.12.2)
84
- nio4r (2.3.1)
85
- nokogiri (1.10.4)
86
- mini_portile2 (~> 2.4.0)
87
- nokogiri (1.10.4-x64-mingw32)
88
- mini_portile2 (~> 2.4.0)
89
- oj (3.9.2)
90
- rack (2.0.6)
68
+ marcel (1.0.1)
69
+ media_types (2.0.1)
70
+ method_source (1.0.0)
71
+ mini_mime (1.1.0)
72
+ minitest (5.14.4)
73
+ nio4r (2.5.7)
74
+ nokogiri (1.11.7-x64-mingw32)
75
+ racc (~> 1.4)
76
+ nokogiri (1.11.7-x86_64-linux)
77
+ racc (~> 1.4)
78
+ oj (3.11.7)
79
+ racc (1.5.2)
80
+ rack (2.2.3)
91
81
  rack-test (1.1.0)
92
82
  rack (>= 1.0, < 3)
93
- rails (5.2.2)
94
- actioncable (= 5.2.2)
95
- actionmailer (= 5.2.2)
96
- actionpack (= 5.2.2)
97
- actionview (= 5.2.2)
98
- activejob (= 5.2.2)
99
- activemodel (= 5.2.2)
100
- activerecord (= 5.2.2)
101
- activestorage (= 5.2.2)
102
- activesupport (= 5.2.2)
83
+ rails (5.2.6)
84
+ actioncable (= 5.2.6)
85
+ actionmailer (= 5.2.6)
86
+ actionpack (= 5.2.6)
87
+ actionview (= 5.2.6)
88
+ activejob (= 5.2.6)
89
+ activemodel (= 5.2.6)
90
+ activerecord (= 5.2.6)
91
+ activestorage (= 5.2.6)
92
+ activesupport (= 5.2.6)
103
93
  bundler (>= 1.3.0)
104
- railties (= 5.2.2)
94
+ railties (= 5.2.6)
105
95
  sprockets-rails (>= 2.0.0)
106
96
  rails-dom-testing (2.0.3)
107
97
  activesupport (>= 4.2.0)
108
98
  nokogiri (>= 1.6)
109
- rails-html-sanitizer (1.0.4)
110
- loofah (~> 2.2, >= 2.2.2)
111
- railties (5.2.2)
112
- actionpack (= 5.2.2)
113
- activesupport (= 5.2.2)
99
+ rails-html-sanitizer (1.3.0)
100
+ loofah (~> 2.3)
101
+ railties (5.2.6)
102
+ actionpack (= 5.2.6)
103
+ activesupport (= 5.2.6)
114
104
  method_source
115
105
  rake (>= 0.8.7)
116
106
  thor (>= 0.19.0, < 2.0)
117
- rake (10.5.0)
118
- sprockets (3.7.2)
107
+ rake (13.0.3)
108
+ sprockets (4.0.2)
119
109
  concurrent-ruby (~> 1.0)
120
110
  rack (> 1, < 3)
121
- sprockets-rails (3.2.1)
111
+ sprockets-rails (3.2.2)
122
112
  actionpack (>= 4.0)
123
113
  activesupport (>= 4.0)
124
114
  sprockets (>= 3.0.0)
125
- thor (0.20.3)
115
+ thor (1.1.0)
126
116
  thread_safe (0.3.6)
127
- tzinfo (1.2.5)
117
+ tzinfo (1.2.9)
128
118
  thread_safe (~> 0.1)
129
- websocket-driver (0.7.0)
119
+ websocket-driver (0.7.5)
130
120
  websocket-extensions (>= 0.1.0)
131
- websocket-extensions (0.1.3)
121
+ websocket-extensions (0.1.5)
132
122
 
133
123
  PLATFORMS
134
- ruby
135
124
  x64-mingw32
125
+ x86_64-linux
136
126
 
137
127
  DEPENDENCIES
138
128
  awesome_print
139
- bundler (~> 2.0)
129
+ bundler
140
130
  media_types-serialization!
141
131
  minitest (~> 5.0)
132
+ oj
142
133
  rails (~> 5.2)
143
- rake (~> 10.0)
134
+ rake (~> 13.0)
144
135
 
145
136
  BUNDLED WITH
146
- 2.0.1
137
+ 2.2.7