meta-api 0.0.2 → 0.0.3

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -4
  3. data/CHANGELOG.md +6 -1
  4. data/Gemfile.lock +1 -1
  5. data/README.md +9 -7
  6. data/docs/Rails.md +61 -0
  7. data/docs//345/246/202/344/275/225/350/264/241/347/214/256.md +10 -0
  8. data/docs//346/225/231/347/250/213.md +21 -21
  9. data/examples/rails_app/.gitattributes +5 -0
  10. data/examples/rails_app/.gitignore +23 -0
  11. data/examples/rails_app/.rspec +1 -0
  12. data/examples/rails_app/.ruby-version +1 -0
  13. data/examples/rails_app/Gemfile +29 -0
  14. data/examples/rails_app/Gemfile.lock +190 -0
  15. data/examples/rails_app/README.md +11 -0
  16. data/examples/rails_app/Rakefile +6 -0
  17. data/examples/rails_app/app/controllers/application_controller.rb +7 -0
  18. data/examples/rails_app/app/controllers/concerns/.keep +0 -0
  19. data/examples/rails_app/app/controllers/data_controller.rb +63 -0
  20. data/examples/rails_app/app/controllers/swagger_controller.rb +13 -0
  21. data/examples/rails_app/app/models/concerns/.keep +0 -0
  22. data/examples/rails_app/bin/rails +4 -0
  23. data/examples/rails_app/bin/rake +4 -0
  24. data/examples/rails_app/bin/setup +25 -0
  25. data/examples/rails_app/config/application.rb +39 -0
  26. data/examples/rails_app/config/boot.rb +3 -0
  27. data/examples/rails_app/config/credentials.yml.enc +1 -0
  28. data/examples/rails_app/config/environment.rb +5 -0
  29. data/examples/rails_app/config/environments/development.rb +51 -0
  30. data/examples/rails_app/config/environments/production.rb +65 -0
  31. data/examples/rails_app/config/environments/test.rb +50 -0
  32. data/examples/rails_app/config/initializers/cors.rb +16 -0
  33. data/examples/rails_app/config/initializers/filter_parameter_logging.rb +8 -0
  34. data/examples/rails_app/config/initializers/inflections.rb +16 -0
  35. data/examples/rails_app/config/initializers/meta_rails_plugin.rb +3 -0
  36. data/examples/rails_app/config/locales/en.yml +33 -0
  37. data/examples/rails_app/config/puma.rb +43 -0
  38. data/examples/rails_app/config/routes.rb +13 -0
  39. data/examples/rails_app/config.ru +6 -0
  40. data/examples/rails_app/lib/tasks/.keep +0 -0
  41. data/examples/rails_app/log/.keep +0 -0
  42. data/examples/rails_app/public/robots.txt +1 -0
  43. data/examples/rails_app/spec/data_controller_spec.rb +60 -0
  44. data/examples/rails_app/spec/rails_helper.rb +55 -0
  45. data/examples/rails_app/spec/spec_helper.rb +94 -0
  46. data/examples/rails_app/spec/swagger_controller_spec.rb +13 -0
  47. data/examples/rails_app/tmp/.keep +0 -0
  48. data/examples/rails_app/tmp/pids/.keep +0 -0
  49. data/lib/meta/application/execution.rb +3 -11
  50. data/lib/meta/application/{meta.rb → metadata.rb} +5 -15
  51. data/lib/meta/application/parameters.rb +47 -0
  52. data/lib/meta/application/route.rb +2 -2
  53. data/lib/meta/json_schema/builders/array_schema_builder.rb +11 -10
  54. data/lib/meta/json_schema/builders/dynamic_schema_builder.rb +23 -0
  55. data/lib/meta/json_schema/builders/object_schema_builder.rb +4 -18
  56. data/lib/meta/json_schema/builders/ref_schema_builder.rb +19 -0
  57. data/lib/meta/json_schema/builders/schema_builder_tool.rb +26 -1
  58. data/lib/meta/json_schema/schemas/array_schema.rb +3 -3
  59. data/lib/meta/json_schema/schemas/base_schema.rb +29 -69
  60. data/lib/meta/json_schema/schemas/dynamic_schema.rb +29 -0
  61. data/lib/meta/json_schema/schemas/object_schema.rb +27 -113
  62. data/lib/meta/json_schema/schemas/properties.rb +157 -0
  63. data/lib/meta/json_schema/schemas/ref_schema.rb +35 -0
  64. data/lib/meta/json_schema/schemas.rb +0 -2
  65. data/lib/meta/json_schema/support/schema_options.rb +21 -12
  66. data/lib/meta/json_schema.rb +2 -0
  67. data/lib/meta/rails.rb +98 -0
  68. data/lib/meta/route_dsl/parameters_builder.rb +2 -1
  69. data/lib/meta/swagger_doc.rb +5 -2
  70. data/lib/meta/utils/kwargs/builder.rb +115 -0
  71. data/lib/meta/utils/{kwargs.rb → kwargs/check.rb} +22 -22
  72. data/meta-api.gemspec +1 -1
  73. metadata +55 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7364c618306dc9d04e6e08784670157e64b57f3f90b1828a259ba713268bb281
4
- data.tar.gz: 00d25192ac7e4b4c733f1aa0d44a2424290d2bc4e290ca99d810686b744ec102
3
+ metadata.gz: 9b4cc662a6a580592192bcc29cd4367249d1bbba4678aee0f95d75d9ff01c219
4
+ data.tar.gz: 5bd5ed38531f286ba422a57b8da12aceb0c13a063be1d5c0895c5073abd5a868
5
5
  SHA512:
6
- metadata.gz: 62eabc56bc4ef76f76cb131f5b901a32875e12b8905857529307dee1acd0a4a354e2822f622f9ef43939444e89e08933e025404050a4347a77fbf169f8a7fe9f
7
- data.tar.gz: 6692c9733a12d3acccc18d1cf6227a084c926dfd69b4acaae872e553683b4e70ca85d1aca874d87c169be1c2a68ca51e62ede1c142ef070829f508b7c2820426
6
+ metadata.gz: b54219704c980114719f6cd9d53d1d77036a194eddd991610b88fe36f52ecf9e04abccfbfaad0d9acd527ba8edc294b333ca403752ff6a0a0f753c30e93d22cd
7
+ data.tar.gz: 564d6e0dfcae8a11aa59bc740e7fff4901326eff996171539156ae064ce205173c548f295e6d0d8cb085fd4de3b829c7141e5cff5aa343e658f8b2475b004d02
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
1
  .DS_Store
2
2
  *.gem
3
- /.idea
4
- /.ruby-version
3
+ .idea
4
+ .ruby-version
5
5
 
6
- /.bundle
7
- /vendor
6
+ .bundle
7
+ vendor
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # 更新日志
2
2
 
3
- ## V0.0.2(2023 年 38 日)
3
+ ## 0.0.3(2023 年 44 日)
4
+
5
+ 1. 添加两个新的选项 `ref:` 和 `dynamic_ref:`,以便后期取代 `using:`.
6
+ 2. 提供 Rails 插件。
7
+
8
+ ## 0.0.2(2023 年 3 月 8 日)
4
9
 
5
10
  1. 添加两个配置项,适合生产环境下使用,用以关闭渲染时的数据验证验证。
6
11
  2. 添加对多态实体的支持。
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meta-api (0.0.2)
4
+ meta-api (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://gems.ruby-china.com/
data/README.md CHANGED
@@ -17,7 +17,7 @@ $ git clone https://github.com/yetrun/web-frame-example.git
17
17
  在 Gemfile 中添加:
18
18
 
19
19
  ```ruby
20
- gem 'meta-api', '~> 0.0.1' # Meta 框架处于快速开发阶段,引入时应尽量固定版本
20
+ gem 'meta-api', '~> 0.0.3' # Meta 框架处于快速开发阶段,引入时应尽量固定版本
21
21
  ```
22
22
 
23
23
  然后在 Ruby 代码中引用:
@@ -26,6 +26,8 @@ gem 'meta-api', '~> 0.0.1' # Meta 框架处于快速开发阶段,引入时应
26
26
  require 'meta/api'
27
27
  ```
28
28
 
29
+ > 或者可嵌入到 Rails 项目中使用,参见[为 Rails 项目带来参数验证效果](docs/Rails.md)。
30
+
29
31
  ## 快速上手
30
32
 
31
33
  ### 定义 API
@@ -37,7 +39,7 @@ class NotesAPI < Meta::Application
37
39
  get '/notes' do
38
40
  title '查看笔记列表'
39
41
  status 200 do
40
- expose :notes, type: 'array', using: NoteEntity
42
+ expose :notes, type: 'array', ref: NoteEntity
41
43
  end
42
44
  action do
43
45
  render :notes, Note.all
@@ -47,10 +49,10 @@ class NotesAPI < Meta::Application
47
49
  post '/notes' do
48
50
  title '创建新的笔记'
49
51
  params do
50
- param :note, type: 'object', using: NoteEntity
52
+ param :note, type: 'object', ref: NoteEntity
51
53
  end
52
54
  status 201 do
53
- expose :note, type: 'object', using: NoteEntity
55
+ expose :note, type: 'object', ref: NoteEntity
54
56
  end
55
57
  action do
56
58
  note = Note.create!(params[:note])
@@ -65,7 +67,7 @@ class NotesAPI < Meta::Application
65
67
  param :id, type: 'integer'
66
68
  end
67
69
  status 200 do
68
- expose :note, type: 'object', using: NoteEntity
70
+ expose :note, type: 'object', ref: NoteEntity
69
71
  end
70
72
  action do
71
73
  note = Note.find(params[:id])
@@ -76,10 +78,10 @@ class NotesAPI < Meta::Application
76
78
  put '/notes/:id' do
77
79
  title '更新笔记'
78
80
  params do
79
- param :note, type: 'object', using: NoteEntity
81
+ param :note, type: 'object', ref: NoteEntity
80
82
  end
81
83
  status 200 do
82
- expose :note, type: 'object', using: NoteEntity
84
+ expose :note, type: 'object', ref: NoteEntity
83
85
  end
84
86
  action do
85
87
  note = Note.find(params[:id])
data/docs/Rails.md ADDED
@@ -0,0 +1,61 @@
1
+ # 作为 Rails 插件
2
+
3
+ ## 安装
4
+
5
+ 首先,你需要将其安装在 Rails 项目中:
6
+
7
+ ```ruby
8
+ gem 'meta-api', '~> 0.0.3' # 0.0.3 版本以上才提供 Rails 插件功能
9
+ ```
10
+
11
+ 在 config/initializers 目录下创建一个文件,例如 `meta_rails_plugin.rb`,并写入:
12
+
13
+ ```ruby
14
+ require 'meta/rails'
15
+
16
+ Meta::Rails.setup
17
+ ```
18
+
19
+ 在 `application_controller.rb` 下加入:
20
+
21
+ ```ruby
22
+ class ApplicationController < ActionController::API
23
+ # 引入插件,同时引入 route 宏、params_on_schema 方法、json_on_schema 渲染器
24
+ include Meta::Rails::Plugin
25
+
26
+ # 处理参数验证错误
27
+ rescue_from Meta::Errors::ParameterInvalid do |e|
28
+ render json: e.errors, status: :bad_request
29
+ end
30
+ end
31
+ ```
32
+
33
+ 这样,一切就准备好了。
34
+
35
+ ## 示例
36
+
37
+ 接口定义:
38
+
39
+ ```ruby
40
+ class UsersController < ApplicationController
41
+ route '/users', :post do
42
+ params do
43
+ param :user, required: true do
44
+ param :name, type: 'string'
45
+ param :age, type: 'integer'
46
+ end
47
+ end
48
+ end
49
+ def create
50
+ user = User.create!(params_on_schema[:user])
51
+ render json_on_schema: user
52
+ end
53
+ end
54
+ ```
55
+
56
+ 生成 Swagger 文档:
57
+
58
+ ```ruby
59
+ Rails.application.eager_load! # 需要提前加载所有常量
60
+ Meta::Rails::Plugin.generate_swagger_doc(ApplicationController)
61
+ ```
@@ -0,0 +1,10 @@
1
+ # 如何贡献
2
+
3
+ ## 发布 Gem
4
+
5
+ 执行两条命令:
6
+
7
+ ```bash
8
+ $ gem build meta-api.gemspec
9
+ $ gem push meta-api-x.x.x.gem
10
+ ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  现有的 Web API 框架并不关注文档的问题,文档往往是作为插件挂载到框架上的。但是,文档和业务实现并不需要割裂开,它们在很大程度上应该是耦合在一起的。比方说,某个接口我定义了参数如此,就该自动生成一致的文档向前端告知;同样,当我提供了文档是如此后,我的接口实现就改自动地约束为这样实现。
4
4
 
5
- Meta 框架(暂定名)天生就是将文档和实现统一起来的,并始终致力于此(如果真的有什么不一致或者不到位的地方,那只能说框架实现上尚有欠缺,并不能从思想上说本该如此)。Meta 框架与 Swagger 合作,致力于产生符合 Restful 和社区规范的文档格式。它提供了几乎完整的描述接口信息的宏命令,并且在描述接口的同时就能基本实现接口的一些约束,其中最重要的莫过于对参数和返回值的声明。
5
+ Meta 框架天生就是将文档和实现统一起来的,并始终致力于此(如果真的有什么不一致或者不到位的地方,那只能说框架实现上尚有欠缺,并不能从思想上说本该如此)。Meta 框架与 Swagger 合作,致力于产生符合 Restful 和社区规范的文档格式。它提供了几乎完整的描述接口信息的宏命令,并且在描述接口的同时就能基本实现接口的一些约束,其中最重要的莫过于对参数和返回值的声明。
6
6
 
7
7
  ## 准备工作
8
8
 
@@ -771,15 +771,15 @@ class UserEntity < Meta::Entity
771
771
  end
772
772
  ```
773
773
 
774
- 然后在 `params` 和 `status` 内部使用 `using` 引用这个实体:
774
+ 然后在 `params` 和 `status` 内部使用 `ref` 引用这个实体:
775
775
 
776
776
  ```ruby
777
777
  params do
778
- param :user, using: UserEntity
778
+ param :user, ref: UserEntity
779
779
  end
780
780
 
781
781
  status 200 do
782
- expose :user, using: UserEntity
782
+ expose :user, ref: UserEntity
783
783
  end
784
784
  ```
785
785
 
@@ -789,11 +789,11 @@ end
789
789
  >
790
790
  > ```ruby
791
791
  > params do
792
- > property :user, using: UserEntity
792
+ > property :user, ref: UserEntity
793
793
  > end
794
794
  >
795
795
  > status 200 do
796
- > property :user, using: UserEntity
796
+ > property :user, ref: UserEntity
797
797
  > end
798
798
  > ```
799
799
 
@@ -805,7 +805,7 @@ end
805
805
 
806
806
  ```ruby
807
807
  params do
808
- param :users, type: "array", using: UserEntity
808
+ param :users, type: "array", ref: UserEntity
809
809
  end
810
810
  ```
811
811
 
@@ -887,7 +887,7 @@ end
887
887
  ```ruby
888
888
  get '/articles' do
889
889
  status 200 do
890
- expose :articles, using: ArticleEntity
890
+ expose :articles, ref: ArticleEntity
891
891
  end
892
892
  action do
893
893
  articles = Article.all
@@ -901,7 +901,7 @@ end
901
901
  ```ruby
902
902
  get '/articles/:id' do
903
903
  status 200 do
904
- expose :article, using: ArticleEntity
904
+ expose :article, ref: ArticleEntity
905
905
  end
906
906
  action do
907
907
  article = Article.find(request.params['id'])
@@ -915,7 +915,7 @@ end
915
915
  ```ruby
916
916
  get '/articles/:id' do
917
917
  status 200 do
918
- expose :article, using: ArticleEntity.lock_scope('full')
918
+ expose :article, ref: ArticleEntity.lock_scope('full')
919
919
  end
920
920
  action do
921
921
  article = Article.find(request.params['id'])
@@ -929,14 +929,14 @@ end
929
929
  ```ruby
930
930
  post '/articles' do
931
931
  params do
932
- param :article, using: ArticleEntity.lock_scope('on_create')
932
+ param :article, ref: ArticleEntity.lock_scope('on_create')
933
933
  end
934
934
  ...
935
935
  end
936
936
 
937
937
  put '/articles/:id' do
938
938
  params do
939
- param :article, using: ArticleEntity.lock_scope('on_update')
939
+ param :article, ref: ArticleEntity.lock_scope('on_update')
940
940
  end
941
941
  ...
942
942
  end
@@ -994,7 +994,7 @@ end
994
994
 
995
995
  ```ruby
996
996
  params do
997
- param :article, using: ArticleEntity
997
+ param :article, ref: ArticleEntity
998
998
  end
999
999
  ```
1000
1000
 
@@ -1034,10 +1034,10 @@ end
1034
1034
 
1035
1035
  ### 多态参数和返回值
1036
1036
 
1037
- 定义属性时可定义多态类型,`using` 选项可接受一个块,它根据值来返回指定的类型:
1037
+ 定义属性时可定义多态类型,`dynamic_ref` 选项可接受一个块,它根据值来返回指定的类型:
1038
1038
 
1039
1039
  ```ruby
1040
- property :target, using: ->(value) {
1040
+ property :target, dynamic_ref: ->(value) {
1041
1041
  # 根据 value.target_type 值返回实体类型
1042
1042
  # 例如,value.target_type == 'UserEntity',将返回 UserEntity 类
1043
1043
  value.target_type.constantize
@@ -1047,7 +1047,7 @@ property :target, using: ->(value) {
1047
1047
  或者接受一个 Hash,这时可提供 `one_of` 选项为文档生成提供加成:
1048
1048
 
1049
1049
  ```ruby
1050
- property :animal, using: {
1050
+ property :animal, dynamic_ref: {
1051
1051
  one_of: [CatEntity, DogEntity, PigEntity],
1052
1052
  resolve: ->(value) { value.animal_type.constantize }
1053
1053
  }
@@ -1098,7 +1098,7 @@ Meta.config.render_validation = false # 渲染时不执行数据验证
1098
1098
 
1099
1099
  ```ruby
1100
1100
  params do
1101
- param :user, using: UserEntity
1101
+ param :user, ref: UserEntity
1102
1102
  end
1103
1103
 
1104
1104
 
@@ -1109,7 +1109,7 @@ end
1109
1109
  但也可以将包裹的外层字段去掉,即将 `UserEntity` 直接用在顶层:
1110
1110
 
1111
1111
  ```ruby
1112
- params using: UserEntity
1112
+ params ref: UserEntity
1113
1113
 
1114
1114
 
1115
1115
  # 接受如下格式的数据
@@ -1119,7 +1119,7 @@ params using: UserEntity
1119
1119
  这个方案同时也支持数组:
1120
1120
 
1121
1121
  ```ruby
1122
- params type: 'array', using: UserEntity
1122
+ params type: 'array', ref: UserEntity
1123
1123
 
1124
1124
  # 接受如下格式的数据
1125
1125
  [
@@ -1190,12 +1190,12 @@ end
1190
1190
 
1191
1191
  > **小提示:**还有一种调用方式 `params(:raw)`,它返回无任何转换逻辑的原生参数。它与 `request.params` 的行为一致。
1192
1192
 
1193
- > **大提示:**如果你是通过 `using:` 引用一个实体定义,另一个更符合语义的方式是使用 `lock` 方法。
1193
+ > **大提示:**如果你是通过 `ref:` 引用一个实体定义,另一个更符合语义的方式是使用 `lock` 方法。
1194
1194
  >
1195
1195
  > ```ruby
1196
1196
  > patch '/users/:id' do
1197
1197
  > params do
1198
- > param :user, using: UserEntity.lock(:discard_missing, true)
1198
+ > param :user, ref: UserEntity.lock(:discard_missing, true)
1199
1199
  > end
1200
1200
  > action do
1201
1201
  > user = User.find(params['id'])
@@ -0,0 +1,5 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+
4
+ # Mark any vendored files as having been vendored.
5
+ vendor/* linguist-vendored
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*
12
+ /tmp/*
13
+ !/log/.keep
14
+ !/tmp/.keep
15
+
16
+ # Ignore pidfiles, but keep the directory.
17
+ /tmp/pids/*
18
+ !/tmp/pids/
19
+ !/tmp/pids/.keep
20
+
21
+
22
+ # Ignore master key for decrypting credentials and more.
23
+ /config/master.key
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 3.1.2
@@ -0,0 +1,29 @@
1
+ source "https://gems.ruby-china.com"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby "3.1.2"
5
+
6
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7
+ gem "rails", "~> 7.0.4"
8
+ gem "meta-api", path: "../.."
9
+
10
+ # Use the Puma web server [https://github.com/puma/puma]
11
+ gem "puma", "~> 5.0"
12
+
13
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
14
+ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
15
+
16
+ # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
17
+ # gem "rack-cors"
18
+
19
+ group :development, :test do
20
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
21
+ gem "debug", platforms: %i[ mri mingw x64_mingw ]
22
+ gem 'rspec-rails', '~> 6.0.0'
23
+ end
24
+
25
+ group :development do
26
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
27
+ # gem "spring"
28
+ end
29
+
@@ -0,0 +1,190 @@
1
+ PATH
2
+ remote: /home/run/workspace/personal/web-frame
3
+ specs:
4
+ meta-api (0.0.2)
5
+
6
+ GEM
7
+ remote: https://gems.ruby-china.com/
8
+ specs:
9
+ actioncable (7.0.4.3)
10
+ actionpack (= 7.0.4.3)
11
+ activesupport (= 7.0.4.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (7.0.4.3)
15
+ actionpack (= 7.0.4.3)
16
+ activejob (= 7.0.4.3)
17
+ activerecord (= 7.0.4.3)
18
+ activestorage (= 7.0.4.3)
19
+ activesupport (= 7.0.4.3)
20
+ mail (>= 2.7.1)
21
+ net-imap
22
+ net-pop
23
+ net-smtp
24
+ actionmailer (7.0.4.3)
25
+ actionpack (= 7.0.4.3)
26
+ actionview (= 7.0.4.3)
27
+ activejob (= 7.0.4.3)
28
+ activesupport (= 7.0.4.3)
29
+ mail (~> 2.5, >= 2.5.4)
30
+ net-imap
31
+ net-pop
32
+ net-smtp
33
+ rails-dom-testing (~> 2.0)
34
+ actionpack (7.0.4.3)
35
+ actionview (= 7.0.4.3)
36
+ activesupport (= 7.0.4.3)
37
+ rack (~> 2.0, >= 2.2.0)
38
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.0)
40
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
+ actiontext (7.0.4.3)
42
+ actionpack (= 7.0.4.3)
43
+ activerecord (= 7.0.4.3)
44
+ activestorage (= 7.0.4.3)
45
+ activesupport (= 7.0.4.3)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (7.0.4.3)
49
+ activesupport (= 7.0.4.3)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.4)
52
+ rails-dom-testing (~> 2.0)
53
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
+ activejob (7.0.4.3)
55
+ activesupport (= 7.0.4.3)
56
+ globalid (>= 0.3.6)
57
+ activemodel (7.0.4.3)
58
+ activesupport (= 7.0.4.3)
59
+ activerecord (7.0.4.3)
60
+ activemodel (= 7.0.4.3)
61
+ activesupport (= 7.0.4.3)
62
+ activestorage (7.0.4.3)
63
+ actionpack (= 7.0.4.3)
64
+ activejob (= 7.0.4.3)
65
+ activerecord (= 7.0.4.3)
66
+ activesupport (= 7.0.4.3)
67
+ marcel (~> 1.0)
68
+ mini_mime (>= 1.1.0)
69
+ activesupport (7.0.4.3)
70
+ concurrent-ruby (~> 1.0, >= 1.0.2)
71
+ i18n (>= 1.6, < 2)
72
+ minitest (>= 5.1)
73
+ tzinfo (~> 2.0)
74
+ builder (3.2.4)
75
+ concurrent-ruby (1.2.2)
76
+ crass (1.0.6)
77
+ date (3.3.3)
78
+ debug (1.7.1)
79
+ irb (>= 1.5.0)
80
+ reline (>= 0.3.1)
81
+ diff-lcs (1.5.0)
82
+ erubi (1.12.0)
83
+ globalid (1.1.0)
84
+ activesupport (>= 5.0)
85
+ i18n (1.12.0)
86
+ concurrent-ruby (~> 1.0)
87
+ io-console (0.6.0)
88
+ irb (1.6.3)
89
+ reline (>= 0.3.0)
90
+ loofah (2.19.1)
91
+ crass (~> 1.0.2)
92
+ nokogiri (>= 1.5.9)
93
+ mail (2.8.1)
94
+ mini_mime (>= 0.1.1)
95
+ net-imap
96
+ net-pop
97
+ net-smtp
98
+ marcel (1.0.2)
99
+ method_source (1.0.0)
100
+ mini_mime (1.1.2)
101
+ minitest (5.18.0)
102
+ net-imap (0.3.4)
103
+ date
104
+ net-protocol
105
+ net-pop (0.1.2)
106
+ net-protocol
107
+ net-protocol (0.2.1)
108
+ timeout
109
+ net-smtp (0.3.3)
110
+ net-protocol
111
+ nio4r (2.5.8)
112
+ nokogiri (1.14.2-x86_64-linux)
113
+ racc (~> 1.4)
114
+ puma (5.6.5)
115
+ nio4r (~> 2.0)
116
+ racc (1.6.2)
117
+ rack (2.2.6.4)
118
+ rack-test (2.1.0)
119
+ rack (>= 1.3)
120
+ rails (7.0.4.3)
121
+ actioncable (= 7.0.4.3)
122
+ actionmailbox (= 7.0.4.3)
123
+ actionmailer (= 7.0.4.3)
124
+ actionpack (= 7.0.4.3)
125
+ actiontext (= 7.0.4.3)
126
+ actionview (= 7.0.4.3)
127
+ activejob (= 7.0.4.3)
128
+ activemodel (= 7.0.4.3)
129
+ activerecord (= 7.0.4.3)
130
+ activestorage (= 7.0.4.3)
131
+ activesupport (= 7.0.4.3)
132
+ bundler (>= 1.15.0)
133
+ railties (= 7.0.4.3)
134
+ rails-dom-testing (2.0.3)
135
+ activesupport (>= 4.2.0)
136
+ nokogiri (>= 1.6)
137
+ rails-html-sanitizer (1.5.0)
138
+ loofah (~> 2.19, >= 2.19.1)
139
+ railties (7.0.4.3)
140
+ actionpack (= 7.0.4.3)
141
+ activesupport (= 7.0.4.3)
142
+ method_source
143
+ rake (>= 12.2)
144
+ thor (~> 1.0)
145
+ zeitwerk (~> 2.5)
146
+ rake (13.0.6)
147
+ reline (0.3.2)
148
+ io-console (~> 0.5)
149
+ rspec-core (3.12.1)
150
+ rspec-support (~> 3.12.0)
151
+ rspec-expectations (3.12.2)
152
+ diff-lcs (>= 1.2.0, < 2.0)
153
+ rspec-support (~> 3.12.0)
154
+ rspec-mocks (3.12.4)
155
+ diff-lcs (>= 1.2.0, < 2.0)
156
+ rspec-support (~> 3.12.0)
157
+ rspec-rails (6.0.1)
158
+ actionpack (>= 6.1)
159
+ activesupport (>= 6.1)
160
+ railties (>= 6.1)
161
+ rspec-core (~> 3.11)
162
+ rspec-expectations (~> 3.11)
163
+ rspec-mocks (~> 3.11)
164
+ rspec-support (~> 3.11)
165
+ rspec-support (3.12.0)
166
+ thor (1.2.1)
167
+ timeout (0.3.2)
168
+ tzinfo (2.0.6)
169
+ concurrent-ruby (~> 1.0)
170
+ websocket-driver (0.7.5)
171
+ websocket-extensions (>= 0.1.0)
172
+ websocket-extensions (0.1.5)
173
+ zeitwerk (2.6.7)
174
+
175
+ PLATFORMS
176
+ x86_64-linux
177
+
178
+ DEPENDENCIES
179
+ debug
180
+ meta-api!
181
+ puma (~> 5.0)
182
+ rails (~> 7.0.4)
183
+ rspec-rails (~> 6.0.0)
184
+ tzinfo-data
185
+
186
+ RUBY VERSION
187
+ ruby 3.1.2p20
188
+
189
+ BUNDLED WITH
190
+ 2.3.17
@@ -0,0 +1,11 @@
1
+ # 测试 Rails 插件
2
+
3
+ 这个项目作为 meta-api 框架用作 Rails 插件的测试项目。请按照以下命令运行:
4
+
5
+ ```bash
6
+ # 安装 gems
7
+ $ bundle install
8
+
9
+ # 运行测试
10
+ $ bin/rails test
11
+ ```
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::API
2
+ include Meta::Rails::Plugin
3
+
4
+ rescue_from Meta::Errors::ParameterInvalid do |e|
5
+ render json: e.errors, status: :bad_request
6
+ end
7
+ end
File without changes