Skip to content

Commit

Permalink
fix: rename configuration request_body_automatically to autodiscover_…
Browse files Browse the repository at this point in the history
…request_body
  • Loading branch information
a-chacon committed Jul 29, 2024
1 parent 559d993 commit 266828e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/oas_rails/configuration.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/oas_rails/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 266828e

Please sign in to comment.