From 349db2e6ebbb9e03aed0f92ec4da04593a9175f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Minaz=CC=8Cek?= Date: Mon, 18 Oct 2021 16:05:51 +0200 Subject: [PATCH 1/3] Added rack gem as dependency, Use Content-Type instead Accept header in example request printer --- Gemfile | 2 ++ lib/dox/printers/example_request_printer.rb | 2 +- spec/fixtures/example.json | 20 +++++++++++++++++++ spec/formatter_spec.rb | 8 ++++---- spec/printers/example_request_printer_spec.rb | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index a662dfc..366b0f7 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,5 @@ gemspec rails_version = ENV['RAILS_VERSION'] || '6.0.2' gem 'activesupport', "~> #{rails_version}" +gem 'rack' + 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 From d1cf196d0effcedeb5b57dfb6cf66358b241ce31 Mon Sep 17 00:00:00 2001 From: Dmytro Pron Date: Mon, 16 Sep 2024 12:19:01 +0200 Subject: [PATCH 2/3] Add rexml gem --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 366b0f7..ff2deec 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,4 @@ rails_version = ENV['RAILS_VERSION'] || '6.0.2' gem 'activesupport', "~> #{rails_version}" gem 'rack' - +gem 'rexml' From 18c20107e7a77731fff43ef68fa472ccd009aba6 Mon Sep 17 00:00:00 2001 From: Dmytro Pron Date: Mon, 16 Sep 2024 12:19:39 +0200 Subject: [PATCH 3/3] Change the ruby version to 3.1.0 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 0cadbc1..a0cd9f0 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.5 +3.1.0 \ No newline at end of file