diff --git a/.ruby-version b/.ruby-version index e261122..fd2a018 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.7 +3.1.0 diff --git a/Gemfile b/Gemfile index a662dfc..ff2deec 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,5 @@ gemspec rails_version = ENV['RAILS_VERSION'] || '6.0.2' gem 'activesupport', "~> #{rails_version}" +gem 'rack' +gem 'rexml' diff --git a/lib/dox/printers/example_request_printer.rb b/lib/dox/printers/example_request_printer.rb index 9f63440..71bfaa0 100644 --- a/lib/dox/printers/example_request_printer.rb +++ b/lib/dox/printers/example_request_printer.rb @@ -47,7 +47,7 @@ def add_schema(body, path) end def find_headers(headers) - headers.find { |key, _| key == 'Accept' }&.last || 'any' + headers.find { |key, _| key == 'Content-Type' }&.last || 'any' end def acquire_header_params diff --git a/spec/fixtures/example.json b/spec/fixtures/example.json index e715f27..0e50941 100644 --- a/spec/fixtures/example.json +++ b/spec/fixtures/example.json @@ -18,6 +18,11 @@ "name": "Accept", "in": "header", "example": "application/json" + }, + { + "name": "Content-Type", + "in": "header", + "example": "application/json" } ], "responses": { @@ -61,6 +66,11 @@ "name": "Accept", "in": "header", "example": "application/json" + }, + { + "name": "Content-Type", + "in": "header", + "example": "application/json" } ], "requestBody": { @@ -132,6 +142,11 @@ "name": "Accept", "in": "header", "example": "application/json" + }, + { + "name": "Content-Type", + "in": "header", + "example": "application/json" } ], "responses": { @@ -176,6 +191,11 @@ "name": "Accept", "in": "header", "example": "application/json" + }, + { + "name": "Content-Type", + "in": "header", + "example": "application/json" } ], "responses": { diff --git a/spec/formatter_spec.rb b/spec/formatter_spec.rb index 3f895ed..12bce96 100644 --- a/spec/formatter_spec.rb +++ b/spec/formatter_spec.rb @@ -24,7 +24,7 @@ path: '/pokemons/14', fullpath: '/pokemons/14', path_parameters: { id: 14 }, - headers: { 'Accept' => 'application/json' } + headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }, response: { status: 200, @@ -64,7 +64,7 @@ } } }, - headers: { 'Accept' => 'application/json' } + headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }, response: { status: 201, @@ -97,7 +97,7 @@ method: 'get', path: '/digimons', fullpath: '/digimons', - headers: { 'Accept' => 'application/json' } + headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }, response: { status: 200, @@ -139,7 +139,7 @@ method: 'get', path: '/auth', fullpath: '/auth', - headers: { 'Accept' => 'application/json' } + headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }, response: { status: 200, diff --git a/spec/printers/example_request_printer_spec.rb b/spec/printers/example_request_printer_spec.rb index 94b26cc..d038433 100644 --- a/spec/printers/example_request_printer_spec.rb +++ b/spec/printers/example_request_printer_spec.rb @@ -56,7 +56,7 @@ ) end - let(:req_headers) { { 'Accept' => content_type } } + let(:req_headers) { { 'Content-Type' => content_type, 'Accept' => content_type } } before do Dox.config.headers_whitelist = nil