easy_talk 3.1.0 → 3.2.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.yardopts +13 -0
  4. data/CHANGELOG.md +75 -0
  5. data/README.md +616 -35
  6. data/Rakefile +27 -0
  7. data/docs/.gitignore +1 -0
  8. data/docs/about.markdown +28 -8
  9. data/docs/getting-started.markdown +102 -0
  10. data/docs/index.markdown +51 -4
  11. data/docs/json_schema_compliance.md +55 -0
  12. data/docs/nested-models.markdown +216 -0
  13. data/docs/property-types.markdown +212 -0
  14. data/docs/schema-definition.markdown +180 -0
  15. data/lib/easy_talk/builders/base_builder.rb +4 -2
  16. data/lib/easy_talk/builders/composition_builder.rb +10 -12
  17. data/lib/easy_talk/builders/object_builder.rb +45 -30
  18. data/lib/easy_talk/builders/registry.rb +168 -0
  19. data/lib/easy_talk/builders/typed_array_builder.rb +15 -4
  20. data/lib/easy_talk/configuration.rb +31 -1
  21. data/lib/easy_talk/error_formatter/base.rb +100 -0
  22. data/lib/easy_talk/error_formatter/error_code_mapper.rb +82 -0
  23. data/lib/easy_talk/error_formatter/flat.rb +38 -0
  24. data/lib/easy_talk/error_formatter/json_pointer.rb +38 -0
  25. data/lib/easy_talk/error_formatter/jsonapi.rb +64 -0
  26. data/lib/easy_talk/error_formatter/path_converter.rb +53 -0
  27. data/lib/easy_talk/error_formatter/rfc7807.rb +69 -0
  28. data/lib/easy_talk/error_formatter.rb +143 -0
  29. data/lib/easy_talk/errors.rb +2 -0
  30. data/lib/easy_talk/errors_helper.rb +63 -34
  31. data/lib/easy_talk/model.rb +123 -90
  32. data/lib/easy_talk/model_helper.rb +13 -0
  33. data/lib/easy_talk/naming_strategies.rb +20 -0
  34. data/lib/easy_talk/property.rb +16 -94
  35. data/lib/easy_talk/ref_helper.rb +27 -0
  36. data/lib/easy_talk/schema.rb +198 -0
  37. data/lib/easy_talk/schema_definition.rb +7 -1
  38. data/lib/easy_talk/schema_methods.rb +80 -0
  39. data/lib/easy_talk/tools/function_builder.rb +1 -1
  40. data/lib/easy_talk/type_introspection.rb +178 -0
  41. data/lib/easy_talk/types/base_composer.rb +2 -1
  42. data/lib/easy_talk/types/composer.rb +4 -0
  43. data/lib/easy_talk/validation_adapters/active_model_adapter.rb +329 -0
  44. data/lib/easy_talk/validation_adapters/base.rb +144 -0
  45. data/lib/easy_talk/validation_adapters/none_adapter.rb +36 -0
  46. data/lib/easy_talk/validation_adapters/registry.rb +87 -0
  47. data/lib/easy_talk/validation_builder.rb +28 -309
  48. data/lib/easy_talk/version.rb +1 -1
  49. data/lib/easy_talk.rb +41 -0
  50. metadata +26 -4
  51. data/docs/404.html +0 -25
  52. data/docs/_posts/2024-05-07-welcome-to-jekyll.markdown +0 -29
  53. data/easy_talk.gemspec +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b091eaff6c33ddcc23f0c5d0147bf28f94a7421c95a0ca47ad917af8e42fad20
4
- data.tar.gz: 9a6c0de5afff453a566940b7b1684e2075e70b53379b2bf3b7583a46ca370c58
3
+ metadata.gz: b77760f0bdffbb877509e133194733d397db6e5963b1484543791169db5dc840
4
+ data.tar.gz: 6e805469940229543c059952dc2311dd9acf7ea89ff45fde8b49b3e4d38dd85d
5
5
  SHA512:
6
- metadata.gz: 32a49bfa38a5279340b6699ff26d8ac415c1574f83da1488d403d422d4b49cd4aea94d5424d858c5ae2326e914c4e83995a97eb67fe4b005543e6f8984d6a60c
7
- data.tar.gz: 02ad31d7b34aac67a4777a709ffb286487675f28e6a2c18757dd87e7a006743ab6cd0f75b817fdb6abb23d3f9ef63384fcbd5f063e1eb2d0dc8a06c7107ae0e0
6
+ metadata.gz: 5bf66646040995f9de8341e2a4e6ea63ae0c462a0f08f28779244e8eceff958e574042450a9a39cc2ef485e13d6c418e5f71296d6d8cc7e958339f432e84c572
7
+ data.tar.gz: 4c26c3bee7751682535f154efef1c4adb86cea08be6c6f09f9ebe08d6a2fde5604d71db884aa7f0de91787118f5bbb719028f8071ec4166ba69af7ad0d9b4ff1
data/.rubocop.yml CHANGED
@@ -114,3 +114,7 @@ Lint/DuplicateBranch:
114
114
 
115
115
  Gemspec/DevelopmentDependencies:
116
116
  Enabled: false
117
+
118
+ Naming/PredicateMethod:
119
+ Exclude:
120
+ - spec/support/schema_validation_matcher.rb
data/.yardopts ADDED
@@ -0,0 +1,13 @@
1
+ --readme README.md
2
+ --title "EasyTalk API Documentation"
3
+ --markup markdown
4
+ --output-dir docs/api
5
+ --protected
6
+ --no-private
7
+ --hide-void-return
8
+ --embed-mixins
9
+ lib/**/*.rb
10
+ -
11
+ README.md
12
+ CHANGELOG.md
13
+ CONSTRAINTS.md
data/CHANGELOG.md CHANGED
@@ -1,3 +1,78 @@
1
+ ## [3.2.0] - 2025-12-28
2
+
3
+ ### Added
4
+
5
+ - **Pluggable Validation Adapter System**: Complete overhaul of the validation layer to make it a distinct, pluggable component (#89)
6
+ - New `EasyTalk::ValidationAdapters::Base` abstract class defining the adapter interface
7
+ - New `EasyTalk::ValidationAdapters::Registry` for adapter registration and lookup
8
+ - New `EasyTalk::ValidationAdapters::ActiveModelAdapter` as the default adapter
9
+ - New `EasyTalk::ValidationAdapters::NoneAdapter` for schema-only use cases
10
+ - Per-model validation configuration: `define_schema(validations: false)`, `define_schema(validations: :none)`, or `define_schema(validations: CustomAdapter)`
11
+ - Per-property validation control with `validate: false` constraint
12
+ - Global configuration via `config.validation_adapter = :active_model`
13
+
14
+ - **Schema-Only Module**: New `EasyTalk::Schema` module for schema generation without ActiveModel (#89)
15
+ - Does not include `ActiveModel::API` or `ActiveModel::Validations`
16
+ - Ideal for API documentation, OpenAPI specs, and schema-first design
17
+
18
+ - **Pluggable Type Registry**: Runtime registration of custom types with their corresponding schema builders (#80)
19
+ - New `EasyTalk::Builders::Registry` class with `register`, `resolve`, `registered?`, `unregister`, `registered_types`, and `reset!` methods
20
+ - Added `EasyTalk.register_type` convenience method at module level
21
+ - Added `config.register_type` for configuration block registration
22
+ - Allows extending EasyTalk with custom types (e.g., Money, GeoPoint) without modifying gem source
23
+
24
+ - **Robust Type Introspection**: New `TypeIntrospection` module replacing brittle string-based type detection (#83)
25
+ - Predicate methods: `boolean_type?`, `typed_array?`, `nilable_type?`, `primitive_type?`
26
+ - Helper methods: `json_schema_type`, `get_type_class`, `extract_inner_type`
27
+ - Uses Sorbet's type system properly instead of string pattern matching
28
+
29
+ - **Standardized Validation Error Output**: Helper methods for API-friendly error formats (#88)
30
+ - **Flat format**: Simple array of field/message/code objects
31
+ - **JSON Pointer (RFC 6901)**: Paths like `/properties/name`
32
+ - **RFC 7807**: Problem Details for HTTP APIs
33
+ - **JSON:API**: Standard JSON:API error format
34
+ - Instance methods: `validation_errors(format:)`, `validation_errors_flat`, `validation_errors_json_pointer`, `validation_errors_rfc7807`, `validation_errors_jsonapi`
35
+ - Configuration options: `default_error_format`, `error_type_base_uri`, `include_error_codes`
36
+
37
+ - **Naming Strategies**: Support for automatic property name transformation (#61)
38
+ - Built-in strategies: `CAMEL_CASE`, `SNAKE_CASE`
39
+ - Optional `as:` property constraint for per-property name override
40
+ - Per-schema configuration: `define_schema { naming_strategy :camel_case }`
41
+ - Global configuration: `config.naming_strategy = :camel_case`
42
+
43
+ - **Array Composition Support**: `T::AnyOf`, `T::OneOf`, and `T::AllOf` now work with `T::Array` (#63)
44
+ - Example: `property :items, T::Array[T::OneOf[ProductA, ProductB]]`
45
+
46
+ - **Nested Model Validation in Arrays**: Arrays of EasyTalk::Model objects are now recursively validated (#112)
47
+ - Hash items in arrays are auto-instantiated to model instances
48
+ - Errors from nested models are merged with indexed paths (e.g., `addresses[0].street`)
49
+
50
+ ### Changed
51
+
52
+ - **Deprecated `EasyTalk::ValidationBuilder`**: Use `EasyTalk::ValidationAdapters::ActiveModelAdapter` instead (deprecation warning shown on first use)
53
+
54
+ ### Fixed
55
+
56
+ - **Default Value Assignment**: Default values are now properly assigned during initialization (#72)
57
+ - **Explicit Nil Preservation**: Explicitly passed `nil` values are preserved instead of being replaced with defaults (#79)
58
+ - **Optional Enum Validation**: Allow `nil` for optional properties with enum constraints (#64)
59
+ - **Optional Pattern Validation**: Allow `nil` for optional properties with pattern validation (#65)
60
+ - **Optional Format Validation**: Allow `nil` for optional properties with format validation (email, uri, uuid, etc.) (#75)
61
+ - **Optional Length Validation**: Allow `nil` for optional properties with length constraints (#76)
62
+ - **Schema Definition Mutation**: Avoid mutating schema definition during property building (#95)
63
+ - **Unknown Property Types**: Fail fast with `UnknownPropertyTypeError` instead of silently returning 'object' (#97)
64
+ - **respond_to_missing?**: Fixed `respond_to_missing?` implementation for additional properties (#98)
65
+ - **VALID_OPTIONS Mutation**: Avoid mutating `VALID_OPTIONS` constant in TypedArrayBuilder (#99)
66
+ - **Registry Reset**: `ValidationAdapters::Registry.reset!` now repopulates defaults (#100)
67
+ - **FunctionBuilder Error**: Replace deprecated Instructor error with `EasyTalk::UnsupportedTypeError` (#96)
68
+ - **Missing snake_case Strategy**: Added `SNAKE_CASE` constant to NamingStrategies module (#77)
69
+
70
+ ### Internal
71
+
72
+ - Extracted shared schema methods into `SchemaMethods` mixin for code reuse between `Model` and `Schema` modules (#103)
73
+ - Centralized built-in type registration in `Builders::Registry` (#102)
74
+ - Added json_schemer for systematic validation testing with custom RSpec matchers
75
+
1
76
  ## [3.1.0] - 2025-12-18
2
77
 
3
78
  ### Added