mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
add oauth flow renaming and warnings
This commit is contained in:
parent
d66be41d04
commit
96fc5276c4
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user