Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auth_api_doc.rb 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require 'swagger/blocks'
  2. module AuthApiDoc
  3. include Swagger::Blocks
  4. MESSAGE_DESC = 'The status of the authentication request.'
  5. MESSAGE_EXAMPLE = 'Generated new API token.'
  6. TOKEN_DESC = 'The Authentication Bearer token'
  7. TOKEN_EXAMPLE = '899d2f45e12429d07427230289400a4594bcffe32169ebb826b4ffa9b90e1d1586f15fa42f069bb7'
  8. # Swagger documentation for auth model
  9. swagger_schema :Auth do
  10. property :message, type: :string, description: MESSAGE_DESC, example: MESSAGE_EXAMPLE
  11. property :token, type: :string, description: TOKEN_DESC, example: TOKEN_EXAMPLE
  12. end
  13. swagger_path '/api/v1/auth/generate-token' do
  14. # Swagger documentation for /api/v1/auth/generate-token POST
  15. operation :post do
  16. key :description, 'Return a valid Authorization Bearer token.'
  17. key :tags, [ 'auth' ]
  18. parameter do
  19. key :in, :body
  20. key :name, :body
  21. key :description, 'Login credentials for the user who will be generating a token.'
  22. key :required, true
  23. schema do
  24. property :username, type: :string, required: true
  25. property :password, type: :string, required: true
  26. end
  27. end
  28. response 200 do
  29. key :description, 'Returns a valid auth token.'
  30. schema do
  31. property :data do
  32. key :'$ref', :Auth
  33. end
  34. end
  35. end
  36. response 401 do
  37. key :description, 'Invalid username or password. ' + RootApiDoc::DEFAULT_RESPONSE_401
  38. schema do
  39. key :'$ref', :AuthErrorModel
  40. end
  41. end
  42. response 500 do
  43. key :description, RootApiDoc::DEFAULT_RESPONSE_500
  44. schema do
  45. key :'$ref', :ErrorModel
  46. end
  47. end
  48. end
  49. end
  50. end