diff --git a/rswag-specs/lib/rswag/specs/swagger_formatter.rb b/rswag-specs/lib/rswag/specs/swagger_formatter.rb index d70cbcd..f87d779 100644 --- a/rswag-specs/lib/rswag/specs/swagger_formatter.rb +++ b/rswag-specs/lib/rswag/specs/swagger_formatter.rb @@ -197,6 +197,14 @@ module Rswag 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 + ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions accessCode is replaced in OpenAPI3! Rename to clientCredentials (in swagger_helper.rb)") + flow = :clientCredentials + end + if flow == :application + ActiveSupport::Deprecation.warn("Rswag::Specs: WARNING: securityDefinitions application is replaced in OpenAPI3! Rename to authorizationCode (in swagger_helper.rb)") + flow = :authorizationCode + 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) end diff --git a/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb b/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb index a233471..2923cb3 100644 --- a/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb +++ b/rswag-specs/spec/rswag/specs/swagger_formatter_spec.rb @@ -78,9 +78,19 @@ module Rswag produces: ['application/vnd.my_mime', 'application/json'], components: { securitySchemes: { - my_oauth: { + myClientCredentials: { type: :oauth2, - flow: :anything, + flow: :accessCode, + token_url: :somewhere + }, + myAuthorizationCode: { + type: :oauth2, + flow: :application, + token_url: :somewhere + }, + myImplicit: { + type: :oauth2, + flow: :implicit, token_url: :somewhere } } @@ -129,10 +139,26 @@ module Rswag expect(swagger_doc.slice(:components)).to match( components: { securitySchemes: { - my_oauth: { + myClientCredentials: { type: :oauth2, flows: { - anything: { + clientCredentials: { + token_url: :somewhere + } + } + }, + myAuthorizationCode: { + type: :oauth2, + flows: { + authorizationCode: { + token_url: :somewhere + } + } + }, + myImplicit: { + type: :oauth2, + flows: { + implicit: { token_url: :somewhere } }