From 1674d93978aabdcab34dfaf568879c897a5733dd Mon Sep 17 00:00:00 2001 From: Pieter Oliver Date: Tue, 22 Oct 2024 19:17:00 +0100 Subject: [PATCH 1/5] Amend some documentation specific typoes --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d53429e0..6a618dac 100644 --- a/README.md +++ b/README.md @@ -485,7 +485,7 @@ add_swagger_documentation \ #### Swagger Header Parameters -Swagger also supports the documentation of parameters passed in the header. Since grape's ```params[]``` doesn't return header parameters we can specify header parameters seperately in a block after the description. +Swagger also supports the documentation of parameters passed in the header. Since grape's ```params[]``` doesn't return header parameters we can specify header parameters separately in a block after the description. ```ruby desc "Return super-secret information", { @@ -955,7 +955,8 @@ The result is then something like following: #### Changing default status codes -The default status codes, one could be found (-> [status codes](lib/grape-swagger/doc_methods/status_codes.rb)) can be changed to your specific needs, to achive it, you have to change it for grape itself and for the documentation. + +The default status codes, one could be found (-> [status codes](lib/grape-swagger/doc_methods/status_codes.rb)) can be changed to your specific needs, to achieve it, you have to change it for grape itself and for the documentation. ```ruby desc 'Get a list of stuff', @@ -1678,7 +1679,7 @@ This is how to configure the grape_swagger documentation: The guard method should inject the Security Requirement Object into the endpoint's route settings (see Grape::DSL::Settings.route_setting method). The 'oauth2 false' added to swagger_documentation is making the main Swagger endpoint protected with OAuth, i.e. the -access_token is being retreiving from the HTTP request, but the 'false' scope is for skipping authorization and +access_token is being retrieving from the HTTP request, but the 'false' scope is for skipping authorization and showing the UI for everyone. If the scope would be set to something else, like 'oauth2 admin', for example, than the UI wouldn't be displayed at all to unauthorized users. @@ -1786,7 +1787,7 @@ params: - store={ true | file_name.json } – save as JSON (optional) - resource=resource_name – get only for this one (optional) ``` -For mutliversion API it creates several files with following naming: file_name_`API_VERSION`.json +For multiversion API it creates several files with following naming: file_name_`API_VERSION`.json #### OpenApi/Swagger Validation From 5bea71cbef1e81dd5b1f217d2ef3a2e03481b34c Mon Sep 17 00:00:00 2001 From: Pieter Oliver Date: Tue, 22 Oct 2024 19:18:54 +0100 Subject: [PATCH 2/5] Address some typoes in tests --- spec/issues/430_entity_definitions_spec.rb | 8 ++++---- ...923_params_schema_definition_for_delete_action_spec.rb | 2 +- spec/support/model_parsers/entity_parser.rb | 2 +- spec/support/model_parsers/mock_parser.rb | 2 +- spec/support/model_parsers/representable_parser.rb | 2 +- spec/swagger_v2/api_swagger_v2_detail_spec.rb | 2 +- spec/swagger_v2/api_swagger_v2_extensions_spec.rb | 4 ++-- spec/swagger_v2/api_swagger_v2_mounted_spec.rb | 2 +- spec/swagger_v2/api_swagger_v2_spec.rb | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/issues/430_entity_definitions_spec.rb b/spec/issues/430_entity_definitions_spec.rb index a9209fe7..f543b6ab 100644 --- a/spec/issues/430_entity_definitions_spec.rb +++ b/spec/issues/430_entity_definitions_spec.rb @@ -37,8 +37,8 @@ class FourthEntity < Grape::Entity end class Class5 - class FithEntity < Class4::FourthEntity - expose :fith_thing + class FifthEntity < Class4::FourthEntity + expose :fifth_thing end end @@ -69,7 +69,7 @@ class NameApi < Grape::API DummyEntities::WithVeryLongName::AnotherGroupingModule::Class2::Entities, DummyEntities::WithVeryLongName::AnotherGroupingModule::Class3::Entity, DummyEntities::WithVeryLongName::AnotherGroupingModule::Class4::FourthEntity, - DummyEntities::WithVeryLongName::AnotherGroupingModule::Class5::FithEntity, + DummyEntities::WithVeryLongName::AnotherGroupingModule::Class5::FifthEntity, DummyEntities::WithVeryLongName::AnotherGroupingModule::Class6::SixthEntity, DummyEntities::WithVeryLongName::AnotherGroupingModule::Class7::SeventhEntity ] @@ -88,7 +88,7 @@ class NameApi < Grape::API specify { expect(subject).to include 'TestDefinition_DummyEntities_WithVeryLongName_AnotherGroupingModule_Class2' } specify { expect(subject).to include 'FooKlass' } specify { expect(subject).to include 'TestDefinition_DummyEntities_WithVeryLongName_AnotherGroupingModule_Class4_FourthEntity' } - specify { expect(subject).to include 'TestDefinition_DummyEntities_WithVeryLongName_AnotherGroupingModule_Class5_FithEntity' } + specify { expect(subject).to include 'TestDefinition_DummyEntities_WithVeryLongName_AnotherGroupingModule_Class5_FifthEntity' } specify { expect(subject).to include 'BarKlass' } specify { expect(subject).to include 'TestDefinition_DummyEntities_WithVeryLongName_AnotherGroupingModule_Class7_SeventhEntity' } end diff --git a/spec/issues/923_params_schema_definition_for_delete_action_spec.rb b/spec/issues/923_params_schema_definition_for_delete_action_spec.rb index a2a228be..f19ad7f2 100644 --- a/spec/issues/923_params_schema_definition_for_delete_action_spec.rb +++ b/spec/issues/923_params_schema_definition_for_delete_action_spec.rb @@ -16,7 +16,7 @@ end end - describe 'retrieves the documentation for delete parameters as a schema defintion' do + describe 'retrieves the documentation for delete parameters as a schema definition' do subject do get '/swagger_doc' JSON.parse(last_response.body) diff --git a/spec/support/model_parsers/entity_parser.rb b/spec/support/model_parsers/entity_parser.rb index f05d1836..3fc2fff3 100644 --- a/spec/support/model_parsers/entity_parser.rb +++ b/spec/support/model_parsers/entity_parser.rb @@ -239,7 +239,7 @@ class DocumentedHashAndArrayModel < Grape::Entity { 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => true }, { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true } ], - 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessible Entity' } }, + 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessable Entity' } }, 'tags' => ['thing'], 'operationId' => 'postThing' } diff --git a/spec/support/model_parsers/mock_parser.rb b/spec/support/model_parsers/mock_parser.rb index ddbb3573..19958be6 100644 --- a/spec/support/model_parsers/mock_parser.rb +++ b/spec/support/model_parsers/mock_parser.rb @@ -247,7 +247,7 @@ class ApiResponse < OpenStruct; end { 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => true }, { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true } ], - 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessible Entity' } }, + 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessable Entity' } }, 'tags' => ['thing'], 'operationId' => 'postThing' } diff --git a/spec/support/model_parsers/representable_parser.rb b/spec/support/model_parsers/representable_parser.rb index 42bf7d88..b92ab7b4 100644 --- a/spec/support/model_parsers/representable_parser.rb +++ b/spec/support/model_parsers/representable_parser.rb @@ -311,7 +311,7 @@ class DocumentedHashAndArrayModel < Representable::Decorator { 'in' => 'formData', 'name' => 'text', 'description' => 'Content of something.', 'type' => 'string', 'required' => true }, { 'in' => 'formData', 'name' => 'links', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true } ], - 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessible Entity' } }, + 'responses' => { '201' => { 'description' => 'This creates Thing.', 'schema' => { '$ref' => '#/definitions/Something' } }, '422' => { 'description' => 'Unprocessable Entity' } }, 'tags' => ['thing'], 'operationId' => 'postThing' } diff --git a/spec/swagger_v2/api_swagger_v2_detail_spec.rb b/spec/swagger_v2/api_swagger_v2_detail_spec.rb index ca789ebf..6e157d65 100644 --- a/spec/swagger_v2/api_swagger_v2_detail_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_detail_spec.rb @@ -23,7 +23,7 @@ def do_good end describe 'details' do - describe 'take deatils as it is' do + describe 'take details as it is' do include_context "#{MODEL_PARSER} swagger example" before :all do diff --git a/spec/swagger_v2/api_swagger_v2_extensions_spec.rb b/spec/swagger_v2/api_swagger_v2_extensions_spec.rb index a3e9fefa..c133867d 100644 --- a/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_extensions_spec.rb @@ -45,7 +45,7 @@ class ExtensionsApi < Grape::API desc 'This returns something with extension on definition level', success: Entities::OtherItem - get '/non_existend_status_definitions_extension' do + get '/non_existent_status_definitions_extension' do { 'declared_params' => declared(params) } end @@ -132,7 +132,7 @@ def app describe 'extension on definition level' do subject do - get '/swagger_doc/non_existend_status_definitions_extension' + get '/swagger_doc/non_existent_status_definitions_extension' JSON.parse(last_response.body) end diff --git a/spec/swagger_v2/api_swagger_v2_mounted_spec.rb b/spec/swagger_v2/api_swagger_v2_mounted_spec.rb index b1400edc..f1371139 100644 --- a/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_mounted_spec.rb @@ -52,7 +52,7 @@ def app requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' } requires :links, type: Array, documentation: { type: 'link', is_array: true } end - post '/thing', http_codes: [{ code: 422, message: 'Unprocessible Entity' }] do + post '/thing', http_codes: [{ code: 422, message: 'Unprocessable Entity' }] do something = OpenStruct.new text: 'something' present something, with: Entities::Something end diff --git a/spec/swagger_v2/api_swagger_v2_spec.rb b/spec/swagger_v2/api_swagger_v2_spec.rb index 5f6c523f..e7dc1702 100644 --- a/spec/swagger_v2/api_swagger_v2_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_spec.rb @@ -51,7 +51,7 @@ def app requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' } requires :links, type: Array, documentation: { type: 'link', is_array: true } end - post '/thing', http_codes: [{ code: 422, message: 'Unprocessible Entity' }] do + post '/thing', http_codes: [{ code: 422, message: 'Unprocessable Entity' }] do something = OpenStruct.new text: 'something' present something, with: Entities::Something end From b042f415f57ce8d2fc75729500b5402ac9e78dca Mon Sep 17 00:00:00 2001 From: Pieter Oliver Date: Tue, 22 Oct 2024 19:20:37 +0100 Subject: [PATCH 3/5] Amend source typo --- spec/support/model_parsers/entity_parser.rb | 2 +- spec/support/model_parsers/mock_parser.rb | 2 +- spec/support/model_parsers/representable_parser.rb | 2 +- spec/swagger_v2/api_swagger_v2_type-format_spec.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/support/model_parsers/entity_parser.rb b/spec/support/model_parsers/entity_parser.rb index 3fc2fff3..5f2a47e9 100644 --- a/spec/support/model_parsers/entity_parser.rb +++ b/spec/support/model_parsers/entity_parser.rb @@ -165,7 +165,7 @@ class DocumentedHashAndArrayModel < Grape::Entity } end - let(:swagger_typed_defintion) do + let(:swagger_typed_definition) do { 'prop_boolean' => { 'description' => 'prop_boolean description', 'type' => 'boolean' }, 'prop_date' => { 'description' => 'prop_date description', 'type' => 'string', 'format' => 'date' }, diff --git a/spec/support/model_parsers/mock_parser.rb b/spec/support/model_parsers/mock_parser.rb index 19958be6..13bdcc04 100644 --- a/spec/support/model_parsers/mock_parser.rb +++ b/spec/support/model_parsers/mock_parser.rb @@ -183,7 +183,7 @@ class ApiResponse < OpenStruct; end } end - let(:swagger_typed_defintion) do + let(:swagger_typed_definition) do { 'mock_data' => { 'type' => 'string', diff --git a/spec/support/model_parsers/representable_parser.rb b/spec/support/model_parsers/representable_parser.rb index b92ab7b4..2102ce8a 100644 --- a/spec/support/model_parsers/representable_parser.rb +++ b/spec/support/model_parsers/representable_parser.rb @@ -237,7 +237,7 @@ class DocumentedHashAndArrayModel < Representable::Decorator } end - let(:swagger_typed_defintion) do + let(:swagger_typed_definition) do { 'prop_boolean' => { 'description' => 'prop_boolean description', 'type' => 'boolean' }, 'prop_date' => { 'description' => 'prop_date description', 'type' => 'string', 'format' => 'date' }, diff --git a/spec/swagger_v2/api_swagger_v2_type-format_spec.rb b/spec/swagger_v2/api_swagger_v2_type-format_spec.rb index 30cc9161..72743a70 100644 --- a/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_type-format_spec.rb @@ -85,6 +85,6 @@ def app end specify do - expect(subject['definitions']['TypedDefinition']['properties']).to eql(swagger_typed_defintion) + expect(subject['definitions']['TypedDefinition']['properties']).to eql(swagger_typed_definition) end end From 37358ed5c8f8d2aeb528b4dc05d6ac693ad012fa Mon Sep 17 00:00:00 2001 From: Pieter Oliver Date: Tue, 22 Oct 2024 19:20:50 +0100 Subject: [PATCH 4/5] Fix typo in parameter call --- lib/grape-swagger/rake/oapi_tasks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grape-swagger/rake/oapi_tasks.rb b/lib/grape-swagger/rake/oapi_tasks.rb index 1fe06791..feea84a2 100644 --- a/lib/grape-swagger/rake/oapi_tasks.rb +++ b/lib/grape-swagger/rake/oapi_tasks.rb @@ -87,7 +87,7 @@ def make_request(url) get url @oapi = JSON.pretty_generate( - JSON.parse(last_response.body, symolize_names: true) + JSON.parse(last_response.body, symbolize_names: true) ) + "\n" end # rubocop:enable Style/StringConcatenation From 88a80051988f9189084faed5ce6ccae2f7e62eb4 Mon Sep 17 00:00:00 2001 From: Pieter Oliver Date: Tue, 22 Oct 2024 19:26:42 +0100 Subject: [PATCH 5/5] Pencil in contribution line --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81707ba4..09ae4c7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Fixes * [#943](https://github.com/ruby-grape/grape-swagger/pull/943): Fix route_param documentation and type - [@4ndv](https://github.com/4ndv) +* [#944](https://github.com/ruby-grape/grape-swagger/pull/944): Amend a few typographic errors - [@pieterocp](https://github.com/pieterocp) * Your contribution here.