mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-23 06:16:42 +00:00
add rewrite for securitySchemes into swagger_doc
This commit is contained in:
parent
e9aebe6221
commit
231a2d135c
@ -56,11 +56,11 @@ module Rswag
|
|||||||
else # Openapi3
|
else # Openapi3
|
||||||
if swagger_doc.has_key?(:securityDefinitions)
|
if swagger_doc.has_key?(:securityDefinitions)
|
||||||
ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
|
ActiveSupport::Deprecation.warn('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
|
||||||
(swagger_doc[:securityDefinitions] || {}).slice(*scheme_names).values
|
swagger_doc[:components] ||= { securitySchemes: swagger_doc[:securityDefinitions] }
|
||||||
else
|
swagger_doc.delete(:securityDefinitions)
|
||||||
components = swagger_doc[:components] || {}
|
|
||||||
(components[:securitySchemes] || {}).slice(*scheme_names).values
|
|
||||||
end
|
end
|
||||||
|
components = swagger_doc[:components] || {}
|
||||||
|
(components[:securitySchemes] || {}).slice(*scheme_names).values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -242,6 +242,7 @@ module Rswag
|
|||||||
expect(request[:headers]).to eq('HTTP_AUTHORIZATION' => 'Basic foobar')
|
expect(request[:headers]).to eq('HTTP_AUTHORIZATION' => 'Basic foobar')
|
||||||
expect(ActiveSupport::Deprecation).to have_received(:warn)
|
expect(ActiveSupport::Deprecation).to have_received(:warn)
|
||||||
.with('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
|
.with('Rswag::Specs: WARNING: securityDefinitions is replaced in OpenAPI3! Rename to components/securitySchemes (in swagger_helper.rb)')
|
||||||
|
expect(swagger_doc[:components]).to have_key(:securitySchemes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -286,14 +286,16 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"securityDefinitions": {
|
"components": {
|
||||||
"basic_auth": {
|
"securitySchemes": {
|
||||||
"type": "basic"
|
"basic_auth": {
|
||||||
},
|
"type": "basic"
|
||||||
"api_key": {
|
},
|
||||||
"type": "apiKey",
|
"api_key": {
|
||||||
"name": "api_key",
|
"type": "apiKey",
|
||||||
"in": "query"
|
"name": "api_key",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user