jpie 0.4.5 → 1.0.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/.gitignore +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +35 -110
- data/.travis.yml +7 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +312 -0
- data/README.md +2072 -140
- data/Rakefile +3 -14
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/jpie.gemspec +18 -35
- data/kiln/app/resources/user_message_resource.rb +2 -0
- data/lib/jpie.rb +3 -24
- data/lib/json_api/active_storage/deserialization.rb +106 -0
- data/lib/json_api/active_storage/detection.rb +74 -0
- data/lib/json_api/active_storage/serialization.rb +32 -0
- data/lib/json_api/configuration.rb +58 -0
- data/lib/json_api/controllers/base_controller.rb +26 -0
- data/lib/json_api/controllers/concerns/controller_helpers.rb +223 -0
- data/lib/json_api/controllers/concerns/resource_actions.rb +657 -0
- data/lib/json_api/controllers/relationships_controller.rb +504 -0
- data/lib/json_api/controllers/resources_controller.rb +6 -0
- data/lib/json_api/errors/parameter_not_allowed.rb +19 -0
- data/lib/json_api/railtie.rb +75 -0
- data/lib/json_api/resources/active_storage_blob_resource.rb +11 -0
- data/lib/json_api/resources/resource.rb +238 -0
- data/lib/json_api/resources/resource_loader.rb +35 -0
- data/lib/json_api/routing.rb +72 -0
- data/lib/json_api/serialization/deserializer.rb +362 -0
- data/lib/json_api/serialization/serializer.rb +320 -0
- data/lib/json_api/support/active_storage_support.rb +85 -0
- data/lib/json_api/support/collection_query.rb +406 -0
- data/lib/json_api/support/instrumentation.rb +42 -0
- data/lib/json_api/support/param_helpers.rb +51 -0
- data/lib/json_api/support/relationship_guard.rb +16 -0
- data/lib/json_api/support/relationship_helpers.rb +74 -0
- data/lib/json_api/support/resource_identifier.rb +87 -0
- data/lib/json_api/support/responders.rb +100 -0
- data/lib/json_api/support/response_helpers.rb +10 -0
- data/lib/json_api/support/sort_parsing.rb +21 -0
- data/lib/json_api/support/type_conversion.rb +21 -0
- data/lib/json_api/testing/test_helper.rb +76 -0
- data/lib/json_api/testing.rb +3 -0
- data/lib/{jpie → json_api}/version.rb +2 -2
- data/lib/json_api.rb +50 -0
- data/lib/rubocop/cop/custom/hash_value_omission.rb +53 -0
- metadata +50 -169
- data/.cursor/rules/dependencies.mdc +0 -19
- data/.cursor/rules/examples.mdc +0 -16
- data/.cursor/rules/git.mdc +0 -14
- data/.cursor/rules/project_structure.mdc +0 -30
- data/.cursor/rules/publish_gem.mdc +0 -73
- data/.cursor/rules/security.mdc +0 -14
- data/.cursor/rules/style.mdc +0 -15
- data/.cursor/rules/testing.mdc +0 -16
- data/.overcommit.yml +0 -35
- data/CHANGELOG.md +0 -164
- data/LICENSE.txt +0 -21
- data/PUBLISHING.md +0 -111
- data/examples/basic_example.md +0 -146
- data/examples/including_related_resources.md +0 -491
- data/examples/pagination.md +0 -303
- data/examples/relationships.md +0 -114
- data/examples/resource_attribute_configuration.md +0 -147
- data/examples/resource_meta_configuration.md +0 -244
- data/examples/rspec_testing.md +0 -130
- data/examples/single_table_inheritance.md +0 -160
- data/lib/jpie/configuration.rb +0 -12
- data/lib/jpie/controller/crud_actions.rb +0 -141
- data/lib/jpie/controller/error_handling/handler_setup.rb +0 -124
- data/lib/jpie/controller/error_handling/handlers.rb +0 -109
- data/lib/jpie/controller/error_handling.rb +0 -23
- data/lib/jpie/controller/json_api_validation.rb +0 -193
- data/lib/jpie/controller/parameter_parsing.rb +0 -78
- data/lib/jpie/controller/related_actions.rb +0 -45
- data/lib/jpie/controller/relationship_actions.rb +0 -291
- data/lib/jpie/controller/relationship_validation.rb +0 -117
- data/lib/jpie/controller/rendering.rb +0 -154
- data/lib/jpie/controller.rb +0 -45
- data/lib/jpie/deserializer.rb +0 -110
- data/lib/jpie/errors.rb +0 -117
- data/lib/jpie/generators/resource_generator.rb +0 -116
- data/lib/jpie/generators/templates/resource.rb.erb +0 -31
- data/lib/jpie/railtie.rb +0 -42
- data/lib/jpie/resource/attributable.rb +0 -112
- data/lib/jpie/resource/inferrable.rb +0 -43
- data/lib/jpie/resource/sortable.rb +0 -93
- data/lib/jpie/resource.rb +0 -147
- data/lib/jpie/routing.rb +0 -59
- data/lib/jpie/serializer.rb +0 -205
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/concern"
|
|
4
|
+
require "rack/utils"
|
|
5
|
+
|
|
6
|
+
module JSONAPI
|
|
7
|
+
module Responders
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
before_action :ensure_jsonapi_content_type, if: -> { request.post? || request.patch? || request.put? }
|
|
12
|
+
before_action :ensure_jsonapi_accept_header
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def ensure_jsonapi_content_type
|
|
18
|
+
return if request.content_type&.include?("application/vnd.api+json")
|
|
19
|
+
|
|
20
|
+
render json: {
|
|
21
|
+
errors: [
|
|
22
|
+
{
|
|
23
|
+
status: "415",
|
|
24
|
+
title: "Unsupported Media Type",
|
|
25
|
+
detail: "Content-Type must be application/vnd.api+json"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}, status: :unsupported_media_type
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def ensure_jsonapi_accept_header
|
|
32
|
+
# Allow requests without Accept header or with */* (browser defaults)
|
|
33
|
+
# Only validate when Accept header is explicitly set to non-JSON:API media types
|
|
34
|
+
accept_header = request.headers["Accept"]
|
|
35
|
+
|
|
36
|
+
# Allow blank Accept header (browser default)
|
|
37
|
+
return if accept_header.blank?
|
|
38
|
+
|
|
39
|
+
# Allow */* Accept header (browser default)
|
|
40
|
+
return if accept_header == "*/*"
|
|
41
|
+
|
|
42
|
+
# Check if request accepts */* (wildcard)
|
|
43
|
+
return if request.accepts.any? { |mime| mime.to_s == "*/*" }
|
|
44
|
+
|
|
45
|
+
# Check if JSON:API media type is explicitly requested
|
|
46
|
+
return if jsonapi_requested?
|
|
47
|
+
|
|
48
|
+
# If Accept header is present and doesn't include JSON:API, return 406
|
|
49
|
+
# This ensures we honor explicit Accept preferences while allowing defaults
|
|
50
|
+
render_not_acceptable_error
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def jsonapi_requested?
|
|
54
|
+
request.accepts.any? { |mime| mime.to_s.include?("application/vnd.api+json") }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def render_not_acceptable_error
|
|
58
|
+
render_parameter_errors(
|
|
59
|
+
[nil],
|
|
60
|
+
title: "Not Acceptable",
|
|
61
|
+
detail_proc: ->(_) { "Accept header must include application/vnd.api+json or be omitted" },
|
|
62
|
+
status: :not_acceptable
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def render_jsonapi_error(status:, title:, detail: nil, source: nil)
|
|
67
|
+
render_jsonapi_errors([{ status:, title:, detail:, source: }], status:)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def render_jsonapi_errors(errors, status:)
|
|
71
|
+
normalized_errors = Array(errors).map do |error|
|
|
72
|
+
normalized = error.compact
|
|
73
|
+
normalized_status = normalized[:status] || status
|
|
74
|
+
normalized[:status] = status_code_for(normalized_status)
|
|
75
|
+
normalized
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
render json: { errors: normalized_errors }, status:
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def render_parameter_errors(values, title:, detail_proc:, source_proc: nil, status: :bad_request)
|
|
82
|
+
errors = Array(values).map do |value|
|
|
83
|
+
error = {
|
|
84
|
+
title:,
|
|
85
|
+
detail: detail_proc.call(value)
|
|
86
|
+
}
|
|
87
|
+
error[:source] = source_proc.call(value) if source_proc
|
|
88
|
+
error
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
render_jsonapi_errors(errors, status:)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def status_code_for(status)
|
|
95
|
+
return status if status.is_a?(String) && status.match?(/\A\d+\z/)
|
|
96
|
+
|
|
97
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(status, status).to_s
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JSONAPI
|
|
4
|
+
module SortParsing
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def parse_sort_field(sort_field)
|
|
8
|
+
descending = sort_field.start_with?("-")
|
|
9
|
+
field = descending ? sort_field[1..] : sort_field
|
|
10
|
+
{ field:, direction: descending ? :desc : :asc }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def extract_sort_field_name(sort_field)
|
|
14
|
+
parse_sort_field(sort_field)[:field]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def extract_sort_direction(sort_field)
|
|
18
|
+
parse_sort_field(sort_field)[:direction]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JSONAPI
|
|
4
|
+
module TypeConversion
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def type_to_class_name(type)
|
|
8
|
+
type.to_s.singularize.classify
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def model_type_name(model_class)
|
|
12
|
+
model_class.name.underscore.pluralize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def resource_type_name(definition_class)
|
|
16
|
+
type_name = definition_class.name.sub(/Resource$/, "").underscore.pluralize
|
|
17
|
+
# Remove namespace prefix if present (e.g., "json_api/active_storage_blobs" -> "active_storage_blobs")
|
|
18
|
+
type_name.split("/").last
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module JSONAPI
|
|
4
|
+
module Testing
|
|
5
|
+
# Test helper for Rails integration/request tests that provides consistent
|
|
6
|
+
# `as: :jsonapi` behavior across all HTTP methods.
|
|
7
|
+
#
|
|
8
|
+
# Usage in RSpec:
|
|
9
|
+
# RSpec.configure do |config|
|
|
10
|
+
# config.include JSONAPI::Testing::TestHelper, type: :request
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# Then use `as: :jsonapi` in your tests:
|
|
14
|
+
# get users_path, params: { filter: { active: true } }, headers:, as: :jsonapi
|
|
15
|
+
# post users_path, params: payload, headers:, as: :jsonapi
|
|
16
|
+
#
|
|
17
|
+
# Behavior:
|
|
18
|
+
# - GET: Sets Accept header, params go to query string (no body encoding)
|
|
19
|
+
# - POST/PATCH/PUT/DELETE: Sets Content-Type and Accept headers, JSON-encodes body
|
|
20
|
+
#
|
|
21
|
+
module TestHelper
|
|
22
|
+
JSONAPI_MIME = "application/vnd.api+json"
|
|
23
|
+
|
|
24
|
+
def get(path, **options)
|
|
25
|
+
if options[:as] == :jsonapi
|
|
26
|
+
options = apply_jsonapi_headers(options, include_content_type: false)
|
|
27
|
+
options.delete(:as)
|
|
28
|
+
end
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def post(path, **options)
|
|
33
|
+
options = apply_jsonapi_options_for_body(options) if options[:as] == :jsonapi
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def patch(path, **options)
|
|
38
|
+
options = apply_jsonapi_options_for_body(options) if options[:as] == :jsonapi
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def put(path, **options)
|
|
43
|
+
options = apply_jsonapi_options_for_body(options) if options[:as] == :jsonapi
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def delete(path, **options)
|
|
48
|
+
options = apply_jsonapi_options_for_body(options) if options[:as] == :jsonapi
|
|
49
|
+
super
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def apply_jsonapi_headers(options, include_content_type: true)
|
|
55
|
+
options = options.dup
|
|
56
|
+
headers = (options[:headers] || {}).dup
|
|
57
|
+
|
|
58
|
+
headers["Accept"] = JSONAPI_MIME
|
|
59
|
+
headers["Content-Type"] = JSONAPI_MIME if include_content_type
|
|
60
|
+
|
|
61
|
+
options[:headers] = headers
|
|
62
|
+
options
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def apply_jsonapi_options_for_body(options)
|
|
66
|
+
options = apply_jsonapi_headers(options, include_content_type: true)
|
|
67
|
+
options.delete(:as)
|
|
68
|
+
|
|
69
|
+
# JSON-encode params for request body
|
|
70
|
+
options[:params] = options[:params].to_json if options[:params].is_a?(Hash)
|
|
71
|
+
|
|
72
|
+
options
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
data/lib/json_api.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json_api/version"
|
|
4
|
+
require "json_api/configuration"
|
|
5
|
+
|
|
6
|
+
module JSONAPI
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
class AuthorizationError < Error; end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require "json_api/errors/parameter_not_allowed"
|
|
12
|
+
|
|
13
|
+
module JSONAPI
|
|
14
|
+
# Rebuild BaseController and RelationshipsController to reflect the current
|
|
15
|
+
# base_controller_class configuration. Safe to call repeatedly.
|
|
16
|
+
def self.rebuild_base_controllers!
|
|
17
|
+
remove_const(:BaseController) if const_defined?(:BaseController)
|
|
18
|
+
load "json_api/controllers/base_controller.rb"
|
|
19
|
+
|
|
20
|
+
remove_const(:RelationshipsController) if const_defined?(:RelationshipsController)
|
|
21
|
+
load "json_api/controllers/relationships_controller.rb"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
require "json_api/resources/resource"
|
|
26
|
+
require "json_api/resources/resource_loader"
|
|
27
|
+
require "json_api/support/type_conversion"
|
|
28
|
+
require "json_api/support/sort_parsing"
|
|
29
|
+
require "json_api/support/resource_identifier"
|
|
30
|
+
require "json_api/support/relationship_helpers"
|
|
31
|
+
require "json_api/support/param_helpers"
|
|
32
|
+
require "json_api/active_storage/detection"
|
|
33
|
+
require "json_api/active_storage/serialization"
|
|
34
|
+
require "json_api/active_storage/deserialization"
|
|
35
|
+
require "json_api/support/active_storage_support"
|
|
36
|
+
require "json_api/support/collection_query"
|
|
37
|
+
require "json_api/routing"
|
|
38
|
+
require "json_api/support/responders"
|
|
39
|
+
require "json_api/support/instrumentation"
|
|
40
|
+
require "json_api/serialization/serializer"
|
|
41
|
+
require "json_api/serialization/deserializer"
|
|
42
|
+
require "json_api/support/response_helpers"
|
|
43
|
+
require "json_api/controllers/concerns/controller_helpers"
|
|
44
|
+
require "json_api/controllers/concerns/resource_actions"
|
|
45
|
+
require "json_api/controllers/base_controller"
|
|
46
|
+
require "json_api/controllers/resources_controller"
|
|
47
|
+
require "json_api/controllers/relationships_controller"
|
|
48
|
+
require "json_api/resources/active_storage_blob_resource" if defined?(ActiveStorage)
|
|
49
|
+
|
|
50
|
+
require "json_api/railtie" if defined?(Rails)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Custom
|
|
6
|
+
# Enforces hash value omission syntax introduced in Ruby 3.1
|
|
7
|
+
# When a hash key and value have the same name, use the shorthand syntax.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# # bad
|
|
11
|
+
# { controller: controller }
|
|
12
|
+
# { foo: foo, bar: bar }
|
|
13
|
+
#
|
|
14
|
+
# # good
|
|
15
|
+
# { controller: }
|
|
16
|
+
# { foo:, bar: }
|
|
17
|
+
class HashValueOmission < Base
|
|
18
|
+
extend AutoCorrector
|
|
19
|
+
|
|
20
|
+
MSG = "Use hash value omission (`%<key>s:`) when the value is the same-named local variable."
|
|
21
|
+
|
|
22
|
+
def on_pair(node)
|
|
23
|
+
return unless valid_pair_for_omission?(node)
|
|
24
|
+
|
|
25
|
+
key_name = node.key.value.to_s
|
|
26
|
+
return if already_omitted?(node, key_name)
|
|
27
|
+
return unless same_name?(node, key_name)
|
|
28
|
+
|
|
29
|
+
add_offense(node, message: format(MSG, key: key_name)) do |corrector|
|
|
30
|
+
corrector.replace(node.source_range, "#{key_name}:")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def valid_pair_for_omission?(node)
|
|
35
|
+
key = node.key
|
|
36
|
+
value = node.value
|
|
37
|
+
|
|
38
|
+
key.sym_type? && value&.lvar_type?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def already_omitted?(node, key_name)
|
|
42
|
+
source = node.source.strip
|
|
43
|
+
source == "#{key_name}:"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def same_name?(node, key_name)
|
|
47
|
+
value_name = node.value.source
|
|
48
|
+
key_name == value_name
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jpie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emil Kampp
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: actionpack
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
@@ -49,183 +49,64 @@ dependencies:
|
|
|
49
49
|
- - ">="
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
51
|
version: 8.0.0
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
|
55
|
-
requirements:
|
|
56
|
-
- - "~>"
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
version: '6.0'
|
|
59
|
-
type: :development
|
|
60
|
-
prerelease: false
|
|
61
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
62
|
-
requirements:
|
|
63
|
-
- - "~>"
|
|
64
|
-
- !ruby/object:Gem::Version
|
|
65
|
-
version: '6.0'
|
|
66
|
-
- !ruby/object:Gem::Dependency
|
|
67
|
-
name: rake
|
|
68
|
-
requirement: !ruby/object:Gem::Requirement
|
|
69
|
-
requirements:
|
|
70
|
-
- - "~>"
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
version: '13.0'
|
|
73
|
-
type: :development
|
|
74
|
-
prerelease: false
|
|
75
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
76
|
-
requirements:
|
|
77
|
-
- - "~>"
|
|
78
|
-
- !ruby/object:Gem::Version
|
|
79
|
-
version: '13.0'
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: rspec
|
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
|
83
|
-
requirements:
|
|
84
|
-
- - "~>"
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: '3.12'
|
|
87
|
-
type: :development
|
|
88
|
-
prerelease: false
|
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
90
|
-
requirements:
|
|
91
|
-
- - "~>"
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: '3.12'
|
|
94
|
-
- !ruby/object:Gem::Dependency
|
|
95
|
-
name: rspec-rails
|
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
requirements:
|
|
98
|
-
- - "~>"
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: '7.0'
|
|
101
|
-
type: :development
|
|
102
|
-
prerelease: false
|
|
103
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
104
|
-
requirements:
|
|
105
|
-
- - "~>"
|
|
106
|
-
- !ruby/object:Gem::Version
|
|
107
|
-
version: '7.0'
|
|
108
|
-
- !ruby/object:Gem::Dependency
|
|
109
|
-
name: rubocop
|
|
110
|
-
requirement: !ruby/object:Gem::Requirement
|
|
111
|
-
requirements:
|
|
112
|
-
- - "~>"
|
|
113
|
-
- !ruby/object:Gem::Version
|
|
114
|
-
version: '1.50'
|
|
115
|
-
type: :development
|
|
116
|
-
prerelease: false
|
|
117
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
118
|
-
requirements:
|
|
119
|
-
- - "~>"
|
|
120
|
-
- !ruby/object:Gem::Version
|
|
121
|
-
version: '1.50'
|
|
122
|
-
- !ruby/object:Gem::Dependency
|
|
123
|
-
name: rubocop-performance
|
|
124
|
-
requirement: !ruby/object:Gem::Requirement
|
|
125
|
-
requirements:
|
|
126
|
-
- - "~>"
|
|
127
|
-
- !ruby/object:Gem::Version
|
|
128
|
-
version: '1.16'
|
|
129
|
-
type: :development
|
|
130
|
-
prerelease: false
|
|
131
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
132
|
-
requirements:
|
|
133
|
-
- - "~>"
|
|
134
|
-
- !ruby/object:Gem::Version
|
|
135
|
-
version: '1.16'
|
|
136
|
-
- !ruby/object:Gem::Dependency
|
|
137
|
-
name: rubocop-rails
|
|
138
|
-
requirement: !ruby/object:Gem::Requirement
|
|
139
|
-
requirements:
|
|
140
|
-
- - "~>"
|
|
141
|
-
- !ruby/object:Gem::Version
|
|
142
|
-
version: '2.18'
|
|
143
|
-
type: :development
|
|
144
|
-
prerelease: false
|
|
145
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
146
|
-
requirements:
|
|
147
|
-
- - "~>"
|
|
148
|
-
- !ruby/object:Gem::Version
|
|
149
|
-
version: '2.18'
|
|
150
|
-
- !ruby/object:Gem::Dependency
|
|
151
|
-
name: rubocop-rspec
|
|
152
|
-
requirement: !ruby/object:Gem::Requirement
|
|
153
|
-
requirements:
|
|
154
|
-
- - "~>"
|
|
155
|
-
- !ruby/object:Gem::Version
|
|
156
|
-
version: '2.20'
|
|
157
|
-
type: :development
|
|
158
|
-
prerelease: false
|
|
159
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
160
|
-
requirements:
|
|
161
|
-
- - "~>"
|
|
162
|
-
- !ruby/object:Gem::Version
|
|
163
|
-
version: '2.20'
|
|
164
|
-
description: JPie provides a framework for developing JSON:API compliant servers with
|
|
165
|
-
Rails 8+. It focuses on clean architecture with strong separation of concerns.
|
|
52
|
+
description: A Rails 8+ gem that provides jsonapi_resources routing DSL and generic
|
|
53
|
+
JSON:API controllers
|
|
166
54
|
email:
|
|
167
|
-
- emil@
|
|
55
|
+
- emil@kampp.me
|
|
168
56
|
executables: []
|
|
169
57
|
extensions: []
|
|
170
58
|
extra_rdoc_files: []
|
|
171
59
|
files:
|
|
172
|
-
- ".
|
|
173
|
-
- ".
|
|
174
|
-
- ".cursor/rules/git.mdc"
|
|
175
|
-
- ".cursor/rules/project_structure.mdc"
|
|
176
|
-
- ".cursor/rules/publish_gem.mdc"
|
|
177
|
-
- ".cursor/rules/security.mdc"
|
|
178
|
-
- ".cursor/rules/style.mdc"
|
|
179
|
-
- ".cursor/rules/testing.mdc"
|
|
180
|
-
- ".overcommit.yml"
|
|
60
|
+
- ".gitignore"
|
|
61
|
+
- ".rspec"
|
|
181
62
|
- ".rubocop.yml"
|
|
182
|
-
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
63
|
+
- ".travis.yml"
|
|
64
|
+
- Gemfile
|
|
65
|
+
- Gemfile.lock
|
|
185
66
|
- README.md
|
|
186
67
|
- Rakefile
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
- examples/pagination.md
|
|
190
|
-
- examples/relationships.md
|
|
191
|
-
- examples/resource_attribute_configuration.md
|
|
192
|
-
- examples/resource_meta_configuration.md
|
|
193
|
-
- examples/rspec_testing.md
|
|
194
|
-
- examples/single_table_inheritance.md
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/setup
|
|
195
70
|
- jpie.gemspec
|
|
71
|
+
- kiln/app/resources/user_message_resource.rb
|
|
196
72
|
- lib/jpie.rb
|
|
197
|
-
- lib/
|
|
198
|
-
- lib/
|
|
199
|
-
- lib/
|
|
200
|
-
- lib/
|
|
201
|
-
- lib/
|
|
202
|
-
- lib/
|
|
203
|
-
- lib/
|
|
204
|
-
- lib/
|
|
205
|
-
- lib/
|
|
206
|
-
- lib/
|
|
207
|
-
- lib/
|
|
208
|
-
- lib/
|
|
209
|
-
- lib/
|
|
210
|
-
- lib/
|
|
211
|
-
- lib/
|
|
212
|
-
- lib/
|
|
213
|
-
- lib/
|
|
214
|
-
- lib/
|
|
215
|
-
- lib/
|
|
216
|
-
- lib/
|
|
217
|
-
- lib/
|
|
218
|
-
- lib/
|
|
219
|
-
- lib/
|
|
220
|
-
- lib/
|
|
221
|
-
|
|
73
|
+
- lib/json_api.rb
|
|
74
|
+
- lib/json_api/active_storage/deserialization.rb
|
|
75
|
+
- lib/json_api/active_storage/detection.rb
|
|
76
|
+
- lib/json_api/active_storage/serialization.rb
|
|
77
|
+
- lib/json_api/configuration.rb
|
|
78
|
+
- lib/json_api/controllers/base_controller.rb
|
|
79
|
+
- lib/json_api/controllers/concerns/controller_helpers.rb
|
|
80
|
+
- lib/json_api/controllers/concerns/resource_actions.rb
|
|
81
|
+
- lib/json_api/controllers/relationships_controller.rb
|
|
82
|
+
- lib/json_api/controllers/resources_controller.rb
|
|
83
|
+
- lib/json_api/errors/parameter_not_allowed.rb
|
|
84
|
+
- lib/json_api/railtie.rb
|
|
85
|
+
- lib/json_api/resources/active_storage_blob_resource.rb
|
|
86
|
+
- lib/json_api/resources/resource.rb
|
|
87
|
+
- lib/json_api/resources/resource_loader.rb
|
|
88
|
+
- lib/json_api/routing.rb
|
|
89
|
+
- lib/json_api/serialization/deserializer.rb
|
|
90
|
+
- lib/json_api/serialization/serializer.rb
|
|
91
|
+
- lib/json_api/support/active_storage_support.rb
|
|
92
|
+
- lib/json_api/support/collection_query.rb
|
|
93
|
+
- lib/json_api/support/instrumentation.rb
|
|
94
|
+
- lib/json_api/support/param_helpers.rb
|
|
95
|
+
- lib/json_api/support/relationship_guard.rb
|
|
96
|
+
- lib/json_api/support/relationship_helpers.rb
|
|
97
|
+
- lib/json_api/support/resource_identifier.rb
|
|
98
|
+
- lib/json_api/support/responders.rb
|
|
99
|
+
- lib/json_api/support/response_helpers.rb
|
|
100
|
+
- lib/json_api/support/sort_parsing.rb
|
|
101
|
+
- lib/json_api/support/type_conversion.rb
|
|
102
|
+
- lib/json_api/testing.rb
|
|
103
|
+
- lib/json_api/testing/test_helper.rb
|
|
104
|
+
- lib/json_api/version.rb
|
|
105
|
+
- lib/rubocop/cop/custom/hash_value_omission.rb
|
|
106
|
+
homepage: https://github.com/klaay/json_api
|
|
222
107
|
licenses:
|
|
223
108
|
- MIT
|
|
224
109
|
metadata:
|
|
225
|
-
allowed_push_host: https://rubygems.org
|
|
226
|
-
homepage_uri: https://github.com/emk-klaay/jpie
|
|
227
|
-
source_code_uri: https://github.com/emk-klaay/jpie.git
|
|
228
|
-
changelog_uri: https://github.com/emk-klaay/jpie/blob/main/CHANGELOG.md
|
|
229
110
|
rubygems_mfa_required: 'true'
|
|
230
111
|
rdoc_options: []
|
|
231
112
|
require_paths:
|
|
@@ -241,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
241
122
|
- !ruby/object:Gem::Version
|
|
242
123
|
version: '0'
|
|
243
124
|
requirements: []
|
|
244
|
-
rubygems_version: 3.
|
|
125
|
+
rubygems_version: 3.7.2
|
|
245
126
|
specification_version: 4
|
|
246
|
-
summary:
|
|
127
|
+
summary: JSON:API compliant Rails gem for producing and consuming JSON:API resources
|
|
247
128
|
test_files: []
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
# Dependency Management
|
|
7
|
-
|
|
8
|
-
## Requirements
|
|
9
|
-
- Keep dependencies minimal and justified
|
|
10
|
-
- Document new dependencies in README.md
|
|
11
|
-
- Keep development dependencies in Gemfile
|
|
12
|
-
- Ensure compatibility with Ruby 3.4+
|
|
13
|
-
- Only support Rails 8+ features
|
|
14
|
-
- Use modern gem versions
|
|
15
|
-
|
|
16
|
-
## Compatibility Requirements
|
|
17
|
-
- Maintain Ruby 3.4+ compatibility
|
|
18
|
-
- Support Rails 8+ integration
|
|
19
|
-
- Follow JSON:API specification strictly
|
data/.cursor/rules/examples.mdc
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
# Example Guidelines
|
|
7
|
-
|
|
8
|
-
- Examples must only include required code
|
|
9
|
-
- Examples must not include any unrelated or superfluous code
|
|
10
|
-
- Examples must be a single markdown file
|
|
11
|
-
- Examples must use the `http` code blocks for examples
|
|
12
|
-
- Examples must only include the minimum number of examples
|
|
13
|
-
- Examples must never include migrations
|
|
14
|
-
- Examples must not include a features section or similar
|
|
15
|
-
- Examples must include an introduction to the example
|
|
16
|
-
- Examples live in /examples/*.md
|
data/.cursor/rules/git.mdc
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
# Git Commit Guidelines
|
|
7
|
-
|
|
8
|
-
- Write clear, descriptive commit messages
|
|
9
|
-
- Keep commits focused and atomic
|
|
10
|
-
- Run and pass tests before committing
|
|
11
|
-
- Update documentation in the same commit as code changes
|
|
12
|
-
- Ignore spec/examples.txt and other files listed in .gitignore
|
|
13
|
-
- Include Ruby/Rails version requirements in relevant commits
|
|
14
|
-
- Update tests in the same commit as code changes
|