meta-api 0.0.7 → 0.0.9

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/meta/application/execution.rb +19 -49
  4. data/lib/meta/application/metadata.rb +65 -5
  5. data/lib/meta/application/route.rb +4 -26
  6. data/lib/meta/config.rb +14 -14
  7. data/lib/meta/json_schema/builders/schema_builder_tool.rb +2 -1
  8. data/lib/meta/json_schema/schemas/array_schema.rb +13 -14
  9. data/lib/meta/json_schema/schemas/base_schema.rb +101 -36
  10. data/lib/meta/json_schema/schemas/object_schema.rb +22 -9
  11. data/lib/meta/json_schema/schemas/properties.rb +20 -74
  12. data/lib/meta/json_schema/schemas/scoping_schema.rb +41 -0
  13. data/lib/meta/json_schema/schemas/staging_schema.rb +58 -0
  14. data/lib/meta/json_schema/schemas/unsupported_schema.rb +22 -0
  15. data/lib/meta/json_schema/support/errors.rb +3 -0
  16. data/lib/meta/json_schema/support/schema_options.rb +0 -9
  17. data/lib/meta/route_dsl/meta_builder.rb +2 -2
  18. data/lib/meta/route_dsl/uniformed_params_builder.rb +5 -5
  19. data/lib/meta/swagger_doc.rb +1 -1
  20. data/lib/meta/utils/kwargs/builder.rb +2 -0
  21. data/lib/meta/utils/route_dsl_builders.rb +1 -0
  22. data/meta-api.gemspec +6 -5
  23. metadata +71 -111
  24. data/.autoenv.zsh +0 -1
  25. data/.gitignore +0 -7
  26. data/.rubocop.yml +0 -28
  27. data/Gemfile +0 -18
  28. data/Gemfile.lock +0 -66
  29. data/README.md +0 -166
  30. data/Rakefile +0 -3
  31. data/docs/Rails.md +0 -61
  32. data/docs//345/220/215/347/247/260/347/224/261/346/235/245.md +0 -7
  33. data/docs//345/246/202/344/275/225/350/264/241/347/214/256.md +0 -10
  34. data/docs//346/225/231/347/250/213.md +0 -1647
  35. data/docs//347/264/242/345/274/225.md +0 -183
  36. data/examples/lobster.rb +0 -71
  37. data/examples/rack_app/README.md +0 -3
  38. data/examples/rack_app/config.ru +0 -6
  39. data/examples/rack_app/hello.rb +0 -6
  40. data/examples/rack_app/timing.rb +0 -15
  41. data/examples/rails_app/.gitattributes +0 -5
  42. data/examples/rails_app/.gitignore +0 -23
  43. data/examples/rails_app/.rspec +0 -1
  44. data/examples/rails_app/.ruby-version +0 -1
  45. data/examples/rails_app/Gemfile +0 -29
  46. data/examples/rails_app/Gemfile.lock +0 -190
  47. data/examples/rails_app/README.md +0 -11
  48. data/examples/rails_app/Rakefile +0 -6
  49. data/examples/rails_app/app/controllers/application_controller.rb +0 -7
  50. data/examples/rails_app/app/controllers/concerns/.keep +0 -0
  51. data/examples/rails_app/app/controllers/data_controller.rb +0 -63
  52. data/examples/rails_app/app/controllers/swagger_controller.rb +0 -13
  53. data/examples/rails_app/app/models/concerns/.keep +0 -0
  54. data/examples/rails_app/bin/rails +0 -4
  55. data/examples/rails_app/bin/rake +0 -4
  56. data/examples/rails_app/bin/setup +0 -25
  57. data/examples/rails_app/config/application.rb +0 -39
  58. data/examples/rails_app/config/boot.rb +0 -3
  59. data/examples/rails_app/config/credentials.yml.enc +0 -1
  60. data/examples/rails_app/config/environment.rb +0 -5
  61. data/examples/rails_app/config/environments/development.rb +0 -51
  62. data/examples/rails_app/config/environments/production.rb +0 -65
  63. data/examples/rails_app/config/environments/test.rb +0 -50
  64. data/examples/rails_app/config/initializers/cors.rb +0 -16
  65. data/examples/rails_app/config/initializers/filter_parameter_logging.rb +0 -8
  66. data/examples/rails_app/config/initializers/inflections.rb +0 -16
  67. data/examples/rails_app/config/initializers/meta_rails_plugin.rb +0 -3
  68. data/examples/rails_app/config/locales/en.yml +0 -33
  69. data/examples/rails_app/config/puma.rb +0 -43
  70. data/examples/rails_app/config/routes.rb +0 -13
  71. data/examples/rails_app/config.ru +0 -6
  72. data/examples/rails_app/lib/tasks/.keep +0 -0
  73. data/examples/rails_app/log/.keep +0 -0
  74. data/examples/rails_app/public/robots.txt +0 -1
  75. data/examples/rails_app/spec/data_controller_spec.rb +0 -60
  76. data/examples/rails_app/spec/rails_helper.rb +0 -55
  77. data/examples/rails_app/spec/spec_helper.rb +0 -94
  78. data/examples/rails_app/spec/swagger_controller_spec.rb +0 -13
  79. data/examples/rails_app/tmp/.keep +0 -0
  80. data/examples/rails_app/tmp/pids/.keep +0 -0
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "fileutils"
3
-
4
- # path to your application root.
5
- APP_ROOT = File.expand_path("..", __dir__)
6
-
7
- def system!(*args)
8
- system(*args) || abort("\n== Command #{args} failed ==")
9
- end
10
-
11
- FileUtils.chdir APP_ROOT do
12
- # This script is a way to set up or update your development environment automatically.
13
- # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
- # Add necessary setup steps to this file.
15
-
16
- puts "== Installing dependencies =="
17
- system! "gem install bundler --conservative"
18
- system("bundle check") || system!("bundle install")
19
-
20
- puts "\n== Removing old logs and tempfiles =="
21
- system! "bin/rails log:clear tmp:clear"
22
-
23
- puts "\n== Restarting application server =="
24
- system! "bin/rails restart"
25
- end
@@ -1,39 +0,0 @@
1
- require_relative "boot"
2
-
3
- require "rails"
4
- # Pick the frameworks you want:
5
- require "active_model/railtie"
6
- # require "active_job/railtie"
7
- # require "active_record/railtie"
8
- # require "active_storage/engine"
9
- require "action_controller/railtie"
10
- # require "action_mailer/railtie"
11
- # require "action_mailbox/engine"
12
- # require "action_text/engine"
13
- require "action_view/railtie"
14
- # require "action_cable/engine"
15
- require "rails/test_unit/railtie"
16
-
17
- # Require the gems listed in Gemfile, including any gems
18
- # you've limited to :test, :development, or :production.
19
- Bundler.require(*Rails.groups)
20
-
21
- module RailsApp
22
- class Application < Rails::Application
23
- # Initialize configuration defaults for originally generated Rails version.
24
- config.load_defaults 7.0
25
-
26
- # Configuration for the application, engines, and railties goes here.
27
- #
28
- # These settings can be overridden in specific environments using the files
29
- # in config/environments, which are processed later.
30
- #
31
- # config.time_zone = "Central Time (US & Canada)"
32
- # config.eager_load_paths << Rails.root.join("extras")
33
-
34
- # Only loads a smaller set of middleware suitable for API only apps.
35
- # Middleware like session, flash, cookies can be added back manually.
36
- # Skip views, helpers and assets when generating a new resource.
37
- config.api_only = true
38
- end
39
- end
@@ -1,3 +0,0 @@
1
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
-
3
- require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -1 +0,0 @@
1
- lvsdM1BYTQWVA7SRjgf5/h8SfdnTnG/YYhQTZ8CztshiP6FzOzb8vAnguQXg8J3it/KQHdEGgK47y2HEirkCr0QUByzbjxR9tqmA383W0AAnLPxn5Gr8Ma8XXkigmXOX4uTZD0nti2Qjq9W0v8X8yFj6xLtUoXpvZ+owPpp5kZgE7ZUeZ05t3X+EoOtCF1m7TNBBiIsyefLLqmwmJneR8R5TWUm6gNiXZXDysPzZBTlovqs93uVFL7WfViZNNWkGUPARrgreugworPRRUx1jqxJQxoOotiSaabUv/6mILkR//okBlxBw3WHS6KONtdgJ35P3BTRSIGniO2qeC5QaUNLfcE7zfLM+21zFVkynsCkBXhsP6IFRzSO1Bs9xIIuj7ror7wxqga8I4Oi0Oj67ErVuQwo3+zNzoek+--27xzMgBPWtwjh/KK--/Yao0rAoDQQqRS4/Y24E+g==
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require_relative "application"
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!
@@ -1,51 +0,0 @@
1
- require "active_support/core_ext/integer/time"
2
-
3
- Rails.application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb.
5
-
6
- # In the development environment your application's code is reloaded any time
7
- # it changes. This slows down response time but is perfect for development
8
- # since you don't have to restart the web server when you make code changes.
9
- config.cache_classes = false
10
-
11
- # Do not eager load code on boot.
12
- config.eager_load = false
13
-
14
- # Show full error reports.
15
- config.consider_all_requests_local = true
16
-
17
- # Enable server timing
18
- config.server_timing = true
19
-
20
- # Enable/disable caching. By default caching is disabled.
21
- # Run rails dev:cache to toggle caching.
22
- if Rails.root.join("tmp/caching-dev.txt").exist?
23
- config.cache_store = :memory_store
24
- config.public_file_server.headers = {
25
- "Cache-Control" => "public, max-age=#{2.days.to_i}"
26
- }
27
- else
28
- config.action_controller.perform_caching = false
29
-
30
- config.cache_store = :null_store
31
- end
32
-
33
- # Print deprecation notices to the Rails logger.
34
- config.active_support.deprecation = :log
35
-
36
- # Raise exceptions for disallowed deprecations.
37
- config.active_support.disallowed_deprecation = :raise
38
-
39
- # Tell Active Support which deprecation messages to disallow.
40
- config.active_support.disallowed_deprecation_warnings = []
41
-
42
-
43
- # Raises error for missing translations.
44
- # config.i18n.raise_on_missing_translations = true
45
-
46
- # Annotate rendered view with file names.
47
- # config.action_view.annotate_rendered_view_with_filenames = true
48
-
49
- # Uncomment if you wish to allow Action Cable access from any origin.
50
- # config.action_cable.disable_request_forgery_protection = true
51
- end
@@ -1,65 +0,0 @@
1
- require "active_support/core_ext/integer/time"
2
-
3
- Rails.application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb.
5
-
6
- # Code is not reloaded between requests.
7
- config.cache_classes = true
8
-
9
- # Eager load code on boot. This eager loads most of Rails and
10
- # your application in memory, allowing both threaded web servers
11
- # and those relying on copy on write to perform better.
12
- # Rake tasks automatically ignore this option for performance.
13
- config.eager_load = true
14
-
15
- # Full error reports are disabled and caching is turned on.
16
- config.consider_all_requests_local = false
17
-
18
- # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
19
- # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
20
- # config.require_master_key = true
21
-
22
- # Disable serving static files from the `/public` folder by default since
23
- # Apache or NGINX already handles this.
24
- config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
25
-
26
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
27
- # config.asset_host = "http://assets.example.com"
28
-
29
- # Specifies the header that your server uses for sending files.
30
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
31
- # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
32
-
33
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
34
- # config.force_ssl = true
35
-
36
- # Include generic and useful information about system operation, but avoid logging too much
37
- # information to avoid inadvertent exposure of personally identifiable information (PII).
38
- config.log_level = :info
39
-
40
- # Prepend all log lines with the following tags.
41
- config.log_tags = [ :request_id ]
42
-
43
- # Use a different cache store in production.
44
- # config.cache_store = :mem_cache_store
45
-
46
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
47
- # the I18n.default_locale when a translation cannot be found).
48
- config.i18n.fallbacks = true
49
-
50
- # Don't log any deprecations.
51
- config.active_support.report_deprecations = false
52
-
53
- # Use default logging formatter so that PID and timestamp are not suppressed.
54
- config.log_formatter = ::Logger::Formatter.new
55
-
56
- # Use a different logger for distributed setups.
57
- # require "syslog/logger"
58
- # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
59
-
60
- if ENV["RAILS_LOG_TO_STDOUT"].present?
61
- logger = ActiveSupport::Logger.new(STDOUT)
62
- logger.formatter = config.log_formatter
63
- config.logger = ActiveSupport::TaggedLogging.new(logger)
64
- end
65
- end
@@ -1,50 +0,0 @@
1
- require "active_support/core_ext/integer/time"
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
-
8
- Rails.application.configure do
9
- # Settings specified here will take precedence over those in config/application.rb.
10
-
11
- # Turn false under Spring and add config.action_view.cache_template_loading = true.
12
- config.cache_classes = true
13
-
14
- # Eager loading loads your whole application. When running a single test locally,
15
- # this probably isn't necessary. It's a good idea to do in a continuous integration
16
- # system, or in some way before deploying your code.
17
- config.eager_load = ENV["CI"].present?
18
-
19
- # Configure public file server for tests with Cache-Control for performance.
20
- config.public_file_server.enabled = true
21
- config.public_file_server.headers = {
22
- "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23
- }
24
-
25
- # Show full error reports and disable caching.
26
- config.consider_all_requests_local = true
27
- config.action_controller.perform_caching = false
28
- config.cache_store = :null_store
29
-
30
- # Raise exceptions instead of rendering exception templates.
31
- config.action_dispatch.show_exceptions = false
32
-
33
- # Disable request forgery protection in test environment.
34
- config.action_controller.allow_forgery_protection = false
35
-
36
- # Print deprecation notices to the stderr.
37
- config.active_support.deprecation = :stderr
38
-
39
- # Raise exceptions for disallowed deprecations.
40
- config.active_support.disallowed_deprecation = :raise
41
-
42
- # Tell Active Support which deprecation messages to disallow.
43
- config.active_support.disallowed_deprecation_warnings = []
44
-
45
- # Raises error for missing translations.
46
- # config.i18n.raise_on_missing_translations = true
47
-
48
- # Annotate rendered view with file names.
49
- # config.action_view.annotate_rendered_view_with_filenames = true
50
- end
@@ -1,16 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Avoid CORS issues when API is called from the frontend app.
4
- # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
5
-
6
- # Read more: https://github.com/cyu/rack-cors
7
-
8
- # Rails.application.config.middleware.insert_before 0, Rack::Cors do
9
- # allow do
10
- # origins "example.com"
11
- #
12
- # resource "*",
13
- # headers: :any,
14
- # methods: [:get, :post, :put, :patch, :delete, :options, :head]
15
- # end
16
- # end
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
- # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
- # notations and behaviors.
6
- Rails.application.config.filter_parameters += [
7
- :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8
- ]
@@ -1,16 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format. Inflections
4
- # are locale specific, and you may define rules for as many different
5
- # locales as you wish. All of these examples are active by default:
6
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, "\\1en"
8
- # inflect.singular /^(ox)en/i, "\\1"
9
- # inflect.irregular "person", "people"
10
- # inflect.uncountable %w( fish sheep )
11
- # end
12
-
13
- # These inflection rules are supported but not enabled by default:
14
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym "RESTful"
16
- # end
@@ -1,3 +0,0 @@
1
- require 'meta/rails'
2
-
3
- Meta::Rails.setup
@@ -1,33 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t "hello"
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t("hello") %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # The following keys must be escaped otherwise they will not be retrieved by
20
- # the default I18n backend:
21
- #
22
- # true, false, on, off, yes, no
23
- #
24
- # Instead, surround them with single quotes.
25
- #
26
- # en:
27
- # "true": "foo"
28
- #
29
- # To learn more, please read the Rails Internationalization guide
30
- # available at https://guides.rubyonrails.org/i18n.html.
31
-
32
- en:
33
- hello: "Hello world"
@@ -1,43 +0,0 @@
1
- # Puma can serve each request in a thread from an internal thread pool.
2
- # The `threads` method setting takes two numbers: a minimum and maximum.
3
- # Any libraries that use thread pools should be configured to match
4
- # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
- # and maximum; this matches the default thread size of Active Record.
6
- #
7
- max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
- min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
- threads min_threads_count, max_threads_count
10
-
11
- # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
- # terminating a worker in development environments.
13
- #
14
- worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15
-
16
- # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
- #
18
- port ENV.fetch("PORT") { 3000 }
19
-
20
- # Specifies the `environment` that Puma will run in.
21
- #
22
- environment ENV.fetch("RAILS_ENV") { "development" }
23
-
24
- # Specifies the `pidfile` that Puma will use.
25
- pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
-
27
- # Specifies the number of `workers` to boot in clustered mode.
28
- # Workers are forked web server processes. If using threads and workers together
29
- # the concurrency of the application would be max `threads` * `workers`.
30
- # Workers do not work on JRuby or Windows (both of which do not support
31
- # processes).
32
- #
33
- # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
-
35
- # Use the `preload_app!` method when specifying a `workers` number.
36
- # This directive tells Puma to first boot the application and load code
37
- # before forking the application. This takes advantage of Copy On Write
38
- # process behavior so workers use less memory.
39
- #
40
- # preload_app!
41
-
42
- # Allow puma to be restarted by `bin/rails restart` command.
43
- plugin :tmp_restart
@@ -1,13 +0,0 @@
1
- Rails.application.routes.draw do
2
- # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
-
4
- # Defines the root path route ("/")
5
- # root "articles#index"
6
-
7
- post '/parse_params', to: 'data#parse_params'
8
- post '/render_hash', to: 'data#render_hash'
9
- post '/render_object', to: 'data#render_object'
10
- post '/render_with_options', to: 'data#render_with_options'
11
-
12
- get '/swagger_doc', to: 'swagger#get_spec'
13
- end
@@ -1,6 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require_relative "config/environment"
4
-
5
- run Rails.application
6
- Rails.application.load_server
File without changes
File without changes
@@ -1 +0,0 @@
1
- # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -1,60 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe "DataController", type: :request do
4
- describe "参数" do
5
- it "过滤参数到 params,原始参数存储到 raw_params" do
6
- post '/parse_params', params: { q: 'q', user: {} }, as: :json
7
- expect(response.status).to eq(200)
8
-
9
- response_body = JSON.parse(response.body)
10
- # params 被修改,同时保留 controller 和 action 参数
11
- expect(response_body['params_on_schema']).to eq(
12
- 'q' => 'q',
13
- 'user' => { 'name' => 'Jim', 'age' => 18 }
14
- )
15
- end
16
-
17
- it "参数异常自动捕获" do
18
- post '/parse_params', params: {}, as: :json
19
- expect(response.status).to eq(400)
20
- end
21
- end
22
-
23
- describe '渲染' do
24
- it "默认值设定起作用" do
25
- post '/render_hash', params: { user: {} }, as: :json
26
- expect(response.status).to eq(200)
27
-
28
- response_body = JSON.parse(response.body)
29
- expect(response_body['user']).to eq('name' => 'Jim', 'age' => 18)
30
- end
31
-
32
- it "使用不同的块定义" do
33
- post '/render_hash', params: { user: {}, status: 201 }, as: :json
34
- expect(response.status).to eq(201)
35
-
36
- response_body = JSON.parse(response.body)
37
- expect(response_body['user']).to eq('name' => 'Jack', 'age' => 20)
38
- end
39
-
40
- describe 'render object' do
41
- it "render 一个对象" do
42
- post '/render_object'
43
- expect(response.status).to eq(200)
44
-
45
- response_body = JSON.parse(response.body)
46
- expect(response_body['user']).to eq('name' => 'Jim', 'age' => 18)
47
- end
48
- end
49
-
50
- context 'with execution:, stage:, scope:' do
51
- it "使用选项" do
52
- post '/render_with_options', params: { user: { a: 'a', b: 'b', c: 'c', d: 'd' }, status: 202 }, as: :json
53
- expect(response.status).to eq(200)
54
-
55
- response_body = JSON.parse(response.body)
56
- expect(response_body['user']).to eq('a' => 'aa', 'b' => 'b')
57
- end
58
- end
59
- end
60
- end
@@ -1,55 +0,0 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- require 'spec_helper'
3
- ENV['RAILS_ENV'] ||= 'test'
4
- require_relative '../config/environment'
5
- # Prevent database truncation if the environment is production
6
- abort("The Rails environment is running in production mode!") if Rails.env.production?
7
- require 'rspec/rails'
8
- # Add additional requires below this line. Rails is not loaded until this point!
9
-
10
- # Requires supporting ruby files with custom matchers and macros, etc, in
11
- # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
- # run as spec files by default. This means that files in spec/support that end
13
- # in _spec.rb will both be required and run as specs, causing the specs to be
14
- # run twice. It is recommended that you do not name files matching this glob to
15
- # end with _spec.rb. You can configure this pattern with the --pattern
16
- # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
- #
18
- # The following line is provided for convenience purposes. It has the downside
19
- # of increasing the boot-up time by auto-requiring all files in the support
20
- # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
- # require only the support files necessary.
22
- #
23
- # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
24
-
25
- RSpec.configure do |config|
26
- # Remove this line to enable support for ActiveRecord
27
- config.use_active_record = false
28
-
29
- # If you enable ActiveRecord support you should uncomment these lines,
30
- # note if you'd prefer not to run each example within a transaction, you
31
- # should set use_transactional_fixtures to false.
32
- #
33
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
34
- # config.use_transactional_fixtures = true
35
-
36
- # RSpec Rails can automatically mix in different behaviours to your tests
37
- # based on their file location, for example enabling you to call `get` and
38
- # `post` in specs under `spec/controllers`.
39
- #
40
- # You can disable this behaviour by removing the line below, and instead
41
- # explicitly tag your specs with their type, e.g.:
42
- #
43
- # RSpec.describe UsersController, type: :controller do
44
- # # ...
45
- # end
46
- #
47
- # The different available types are documented in the features, such as in
48
- # https://relishapp.com/rspec/rspec-rails/docs
49
- config.infer_spec_type_from_file_location!
50
-
51
- # Filter lines from Rails gems in backtraces.
52
- config.filter_rails_from_backtrace!
53
- # arbitrary gems may also be filtered via:
54
- # config.filter_gems_from_backtrace("gem name")
55
- end
@@ -1,94 +0,0 @@
1
- # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
- #
15
- # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
- RSpec.configure do |config|
17
- # rspec-expectations config goes here. You can use an alternate
18
- # assertion/expectation library such as wrong or the stdlib/minitest
19
- # assertions if you prefer.
20
- config.expect_with :rspec do |expectations|
21
- # This option will default to `true` in RSpec 4. It makes the `description`
22
- # and `failure_message` of custom matchers include text for helper methods
23
- # defined using `chain`, e.g.:
24
- # be_bigger_than(2).and_smaller_than(4).description
25
- # # => "be bigger than 2 and smaller than 4"
26
- # ...rather than:
27
- # # => "be bigger than 2"
28
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
- end
30
-
31
- # rspec-mocks config goes here. You can use an alternate test double
32
- # library (such as bogus or mocha) by changing the `mock_with` option here.
33
- config.mock_with :rspec do |mocks|
34
- # Prevents you from mocking or stubbing a method that does not exist on
35
- # a real object. This is generally recommended, and will default to
36
- # `true` in RSpec 4.
37
- mocks.verify_partial_doubles = true
38
- end
39
-
40
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
- # have no way to turn it off -- the option exists only for backwards
42
- # compatibility in RSpec 3). It causes shared context metadata to be
43
- # inherited by the metadata hash of host groups and examples, rather than
44
- # triggering implicit auto-inclusion in groups with matching metadata.
45
- config.shared_context_metadata_behavior = :apply_to_host_groups
46
-
47
- # The settings below are suggested to provide a good initial experience
48
- # with RSpec, but feel free to customize to your heart's content.
49
- =begin
50
- # This allows you to limit a spec run to individual examples or groups
51
- # you care about by tagging them with `:focus` metadata. When nothing
52
- # is tagged with `:focus`, all examples get run. RSpec also provides
53
- # aliases for `it`, `describe`, and `context` that include `:focus`
54
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
- config.filter_run_when_matching :focus
56
-
57
- # Allows RSpec to persist some state between runs in order to support
58
- # the `--only-failures` and `--next-failure` CLI options. We recommend
59
- # you configure your source control system to ignore this file.
60
- config.example_status_persistence_file_path = "spec/examples.txt"
61
-
62
- # Limits the available syntax to the non-monkey patched syntax that is
63
- # recommended. For more details, see:
64
- # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
65
- config.disable_monkey_patching!
66
-
67
- # Many RSpec users commonly either run the entire suite or an individual
68
- # file, and it's useful to allow more verbose output when running an
69
- # individual spec file.
70
- if config.files_to_run.one?
71
- # Use the documentation formatter for detailed output,
72
- # unless a formatter has already been configured
73
- # (e.g. via a command-line flag).
74
- config.default_formatter = "doc"
75
- end
76
-
77
- # Print the 10 slowest examples and example groups at the
78
- # end of the spec run, to help surface which specs are running
79
- # particularly slow.
80
- config.profile_examples = 10
81
-
82
- # Run specs in random order to surface order dependencies. If you find an
83
- # order dependency and want to debug it, you can fix the order by providing
84
- # the seed, which is printed after each run.
85
- # --seed 1234
86
- config.order = :random
87
-
88
- # Seed global randomization in this process using the `--seed` CLI option.
89
- # Setting this allows you to use `--seed` to deterministically reproduce
90
- # test failures related to randomization by passing the same `--seed` value
91
- # as the one that triggered the failure.
92
- Kernel.srand config.seed
93
- =end
94
- end
@@ -1,13 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe "SwaggerController", type: :request do
4
- describe '生成 Swagger 文档' do
5
- it "生成文档" do
6
- get '/swagger_doc'
7
- expect(response.status).to eq(200)
8
-
9
- response_body = JSON.parse(response.body)
10
- expect(response_body['paths']).not_to be_empty
11
- end
12
- end
13
- end
File without changes
File without changes