diff --git a/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb b/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb index 9d2f9f2..40a15f4 100644 --- a/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb +++ b/lib/generators/oas_rails/config/templates/oas_rails_initializer.rb @@ -44,6 +44,6 @@ config.tags = [{ name: "Users", description: "Manage the `amazing` Users table." }] # config.default_tags_from = :namespace # Could be: :namespace or :controller - # config.request_body_automatically = true # Try to get request body for create and update methos based on the controller name. + # config.autodiscover_request_body = true # Try to get request body for create and update methods based on the controller name. # config.autodiscover_responses = true # Looks for renders in your source code and try to generate the responses. end diff --git a/lib/oas_rails/configuration.rb b/lib/oas_rails/configuration.rb index e8f8f3a..fec5afa 100644 --- a/lib/oas_rails/configuration.rb +++ b/lib/oas_rails/configuration.rb @@ -1,6 +1,6 @@ module OasRails class Configuration - attr_accessor :info, :default_tags_from, :request_body_automatically, :autodiscover_responses + attr_accessor :info, :default_tags_from, :autodiscover_request_body, :autodiscover_responses attr_reader :servers, :tags def initialize(**kwargs) @@ -9,7 +9,7 @@ def initialize(**kwargs) @tags = [] @swagger_version = '3.1.0' @default_tags_from = "namespace" - @request_body_automatically = true + @autodiscover_request_body = true @autodiscover_responses = true end diff --git a/lib/oas_rails/operation.rb b/lib/oas_rails/operation.rb index 29011ef..21a328a 100644 --- a/lib/oas_rails/operation.rb +++ b/lib/oas_rails/operation.rb @@ -89,7 +89,7 @@ def parameters_from_tags(tags:) def extract_request_body(oas_route:) tag_request_body = oas_route.docstring.tags(:request_body).first - if tag_request_body.nil? && OasRails.config.request_body_automatically + if tag_request_body.nil? && OasRails.config.autodiscover_request_body oas_route.detect_request_body if %w[create update].include? oas_route.method elsif !tag_request_body.nil? RequestBody.from_tags(tag: tag_request_body, examples_tags: oas_route.docstring.tags(:request_body_example))