From f1f8b0ed18e16046b3ba7ddbc0d0285bea5888bc Mon Sep 17 00:00:00 2001 From: Greg Myers Date: Sat, 4 Apr 2020 21:03:04 +0100 Subject: [PATCH] fix oauth corrections correct way round --- rswag-specs/lib/rswag/specs/swagger_formatter.rb | 10 +++++----- rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rswag-specs/lib/rswag/specs/swagger_formatter.rb b/rswag-specs/lib/rswag/specs/swagger_formatter.rb index f87d779..ac4aa64 100644 --- a/rswag-specs/lib/rswag/specs/swagger_formatter.rb +++ b/rswag-specs/lib/rswag/specs/swagger_formatter.rb @@ -196,14 +196,14 @@ module Rswag next unless v.key?(:flow) ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions flow is replaced in OpenAPI3! Rename to components/securitySchemes/#{name}/flows[] (in swagger_helper.rb)") - flow = swagger_doc[:components][:securitySchemes][name].delete(:flow) - if flow == :accessCode + flow = swagger_doc[:components][:securitySchemes][name].delete(:flow).to_s + if flow == 'accessCode' ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions accessCode is replaced in OpenAPI3! Rename to clientCredentials (in swagger_helper.rb)") - flow = :clientCredentials + flow = 'authorizationCode' end - if flow == :application + if flow == 'application' ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions application is replaced in OpenAPI3! Rename to authorizationCode (in swagger_helper.rb)") - flow = :authorizationCode + flow = 'clientCredentials' end flow_elements = swagger_doc[:components][:securitySchemes][name].except(:type).each_with_object({}) do |(k, _v), a| a[k] = swagger_doc[:components][:securitySchemes][name].delete(k) diff --git a/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb b/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb index 2923cb3..7964373 100644 --- a/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb +++ b/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb @@ -80,12 +80,12 @@ module Rswag securitySchemes: { myClientCredentials: { type: :oauth2, - flow: :accessCode, + flow: :application, token_url: :somewhere }, myAuthorizationCode: { type: :oauth2, - flow: :application, + flow: :accessCode, token_url: :somewhere }, myImplicit: { @@ -142,7 +142,7 @@ module Rswag myClientCredentials: { type: :oauth2, flows: { - clientCredentials: { + 'clientCredentials' => { token_url: :somewhere } } @@ -150,7 +150,7 @@ module Rswag myAuthorizationCode: { type: :oauth2, flows: { - authorizationCode: { + 'authorizationCode' => { token_url: :somewhere } } @@ -158,7 +158,7 @@ module Rswag myImplicit: { type: :oauth2, flows: { - implicit: { + 'implicit' => { token_url: :somewhere } }