Advertisement
Guest User

Untitled

a guest
Jun 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 13.82 KB | None | 0 0
  1. swagger: '2.0'
  2. info:
  3.   version: 0.0.1
  4.   title: Lottery Server
  5. host: 'localhost:3141'
  6. basePath: /
  7. schemes:
  8.  - http
  9.   - https
  10. consumes:
  11.  - application/json
  12. produces:
  13.  - application/json
  14. paths:
  15.   /user:
  16.     x-swagger-router-controller: user.routes
  17.     get:
  18.       tags:
  19.         - User
  20.       summary: get all users (admin only)
  21.       operationId: getUsers
  22.       responses:
  23.         '200':
  24.           description: Success
  25.           schema:
  26.             type: array
  27.             items:
  28.               $ref: '#/definitions/userInfo'
  29.     post:
  30.       tags:
  31.         - User
  32.       summary: add a new user (admin only)
  33.       operationId: addUser
  34.       parameters:
  35.         - name: body
  36.           in: body
  37.           description: info of the user you wish to register
  38.           required: true
  39.           schema:
  40.             $ref: '#/definitions/userRegisterInfo'
  41.       responses:
  42.         '200':
  43.           description: Success
  44.           schema:
  45.             $ref: '#/definitions/userInfo'
  46.         default:
  47.           description: Error
  48.           schema:
  49.             $ref: '#/definitions/ErrorResponse'
  50.   /user/addCredit:
  51.     x-swagger-router-controller: user.routes
  52.     post:
  53.       tags:
  54.         - User
  55.       summary: add credit for user (admin only)
  56.       operationId: addCredit
  57.       parameters:
  58.         - name: body
  59.           in: body
  60.           description: user name and credit to add
  61.           schema:
  62.             $ref: '#/definitions/userAndCredit'
  63.       responses:
  64.         '200':
  65.           description: Success
  66.           schema:
  67.             $ref: '#/definitions/SuccessResponse'
  68.         default:
  69.           description: Error
  70.           schema:
  71.             $ref: '#/definitions/ErrorResponse'
  72.   /user/changePassword:
  73.     x-swagger-router-controller: user.routes
  74.     post:
  75.       tags:
  76.         - User
  77.       summary: change user password (admin only)
  78.       operationId: changePassword
  79.       parameters:
  80.         - name: userAndPassword
  81.           in: body
  82.           description: user name and new password
  83.           schema:
  84.             $ref: '#/definitions/userAndPassword'
  85.       responses:
  86.         '200':
  87.           description: Success
  88.           schema:
  89.             $ref: '#/definitions/SuccessResponse'
  90.         default:
  91.           description: Error
  92.           schema:
  93.             $ref: '#/definitions/ErrorResponse'
  94.   /lottery:
  95.     x-swagger-router-controller: lottery.routes
  96.     get:
  97.       tags:
  98.        - Lottery
  99.       summary: Get lotteries
  100.       description: can be filtered by name, type, isClosed or hasResult
  101.       parameters:
  102.         - name: lotteryName
  103.           in: query
  104.           description: lotteryName
  105.           type: string
  106.         - name: lotteryType
  107.           in: query
  108.           description: type of lottery
  109.           type: string
  110.           enum:
  111.            [loto, toto]
  112.         - name: isClosed
  113.           in: query
  114.           description: has lottery been closed by admin
  115.           type: boolean
  116.         - name: hasResult
  117.           in: query
  118.           description: has lottery result been submitted by admin
  119.           type: boolean
  120.       responses:
  121.         '200':
  122.           description: Success
  123.           schema:
  124.             type: array
  125.             items:
  126.               $ref: '#/definitions/lottery'
  127.         default:
  128.           description: Error
  129.           schema:
  130.             $ref: '#/definitions/ErrorResponse'
  131.     post:
  132.       tags:
  133.        - Lottery
  134.       summary: Add a new lottery (admin only)
  135.       operationId: addLottery
  136.       parameters:
  137.         - name: newLottery
  138.           in: body
  139.           schema:
  140.             $ref: '#/definitions/newLottery'
  141.       responses:
  142.         '200':
  143.           description: Success
  144.           schema:
  145.             $ref: '#/definitions/lottery'
  146.         default:
  147.           description: Error
  148.           schema:
  149.             $ref: '#/definitions/ErrorResponse'
  150.   /lottery/close:
  151.     x-swagger-router-controller: lottery.routes
  152.     post:
  153.       tags:
  154.        - Lottery
  155.       operationId: closeLottery
  156.       summary: close lottery so there will be no new bets (admin only)
  157.       parameters:
  158.         - name: lotteryId
  159.           in: body
  160.           schema:
  161.             type: string
  162.       responses:
  163.         '200':
  164.           description: Success
  165.           schema:
  166.             $ref: '#/definitions/lottery'
  167.         default:
  168.           description: Error
  169.           schema:
  170.             $ref: '#/definitions/ErrorResponse'
  171.   /lottery/submitResult:
  172.     x-swagger-router-controller: lottery.routes
  173.     post:
  174.       tags:
  175.        - Lottery
  176.       operationId: submitResult
  177.       summary: Submit lottery result
  178.       description: Submit lottery result
  179.       parameters:
  180.         - name: lotteryIdAndResult
  181.           in: body
  182.           schema:
  183.             $ref: '#/definitions/lotteryIdAndResult'
  184.       responses:
  185.         '200':
  186.           description: Success
  187.           schema:
  188.             $ref: '#/definitions/lottery'
  189.         default:
  190.           description: Error
  191.           schema:
  192.             $ref: '#/definitions/ErrorResponse'
  193.   /lottery/submitPassword:
  194.     x-swagger-router-controller: lottery.routes
  195.     post:
  196.       tags:
  197.        - Lottery
  198.       operationId: submitPassword
  199.       parameters:
  200.         - name: lotteryIdAndPassword
  201.           in: body
  202.           schema:
  203.             type: object
  204.             properties:
  205.               lotteryId:
  206.                 type: string
  207.               password:
  208.                 type: string
  209.       responses:
  210.         '200':
  211.           description: Success
  212.           schema:
  213.             $ref: '#/definitions/lottery'
  214.         '403':
  215.           description: Wrong Password
  216.           schema:
  217.             $ref: '#/definitions/ErrorResponse'
  218.         default:
  219.           description: Error
  220.           schema:
  221.             $ref: '#/definitions/ErrorResponse'
  222.   /bet:
  223.     post:
  224.       tags:
  225.         - Bet
  226.       summary: add a new bet
  227.       parameters:
  228.         - name: newBet
  229.           in: body
  230.           schema:
  231.             $ref: '#/definitions/newBet'
  232.       responses:
  233.         200:
  234.           description: Success
  235.           schema:
  236.             $ref: '#/definitions/SuccessResponse'
  237.   /bet/_search:
  238.     post:
  239.       tags:
  240.         - Bet
  241.       summary: get all bets, can filter by any bet field
  242.       operationId: getBets
  243.       parameters:
  244.         - name: betFields
  245.           in: body
  246.           description: filter by any field of bet, can be left empty to return all bets
  247.           schema:
  248.             type: object
  249.             properties:
  250.               betId:
  251.                 type: string
  252.               lotteryId:
  253.                 type: string
  254.               userName:
  255.                 type: string
  256.        
  257.       responses:
  258.         '200':
  259.           description: Success
  260.           schema:
  261.             type: array
  262.             items:
  263.               $ref: '#/definitions/bet'
  264.         default:
  265.           description: Error
  266.           schema:
  267.             $ref: '#/definitions/ErrorResponse'
  268.   /bet/won:
  269.     get:
  270.       tags:
  271.        - Bet
  272.       summary: get bets that have been successfull
  273.       description: get bets that have been successfull, retrieve either by userName, lotteryId or all won bets
  274.       operationId: getWonBets
  275.       parameters:
  276.         - in: query
  277.           name: userName
  278.           type: string
  279.         - in: query
  280.           name: lotteryId
  281.           type: string
  282.       responses:
  283.         '200':
  284.           description: Sucess
  285.           schema:
  286.             type: array
  287.             items:
  288.               $ref: '#/definitions/wonBet'
  289.         default:
  290.           description: Error
  291.           schema:
  292.             $ref: '#/definitions/ErrorResponse'
  293.   /adminMessage:
  294.     x-swagger-router-controller: adminMessage.routes
  295.     get:
  296.       tags:
  297.         - Admin Message
  298.       summary: get all admin messages (admin only)
  299.       operationId: getAdminMessages
  300.       responses:
  301.         '200':
  302.           description: Success
  303.           schema:
  304.             type: array
  305.             items:
  306.               type: object
  307.               properties:
  308.                 id:
  309.                   type: string
  310.                 text:
  311.                   type: string
  312.                 isModal:
  313.                   type: boolean
  314.     post:
  315.       tags:
  316.         - Admin Message
  317.       summary: adds a new admin message (admin only)
  318.       operationId: addAdminMessage
  319.       parameters:
  320.         - name: body
  321.           in: body
  322.           required: true
  323.           schema:
  324.             $ref: '#/definitions/adminMessage'
  325.            
  326.       responses:
  327.         '200':
  328.           description: Success
  329.           schema:
  330.             $ref: '#/definitions/SuccessResponse'
  331.         default:
  332.           description: Error
  333.           schema:
  334.             $ref: '#/definitions/ErrorResponse'
  335.   /swagger:
  336.     x-swagger-pipe: swagger_raw
  337. definitions:
  338.   userRegisterInfo:
  339.     required:
  340.       - userName
  341.       - name
  342.       - password
  343.     properties:
  344.       userName:
  345.         type: string
  346.       name:
  347.         type: string
  348.       password:
  349.         type: string
  350.       credit:
  351.         type: number
  352.   userInfo:
  353.     properties:
  354.       userName:
  355.         type: string
  356.       name:
  357.         type: string
  358.       credit:
  359.         type: number
  360.   userAndCredit:
  361.     required:
  362.      - userName
  363.       - credit
  364.     properties:
  365.       userName:
  366.         type: string
  367.       credit:
  368.         type: number
  369.   userAndPassword:
  370.     required:
  371.      - userName
  372.       - password
  373.     properties:
  374.       userName:
  375.         type: string
  376.       password:
  377.         type: string
  378.   lottery:
  379.     properties:
  380.       id:
  381.         type: string
  382.       name:
  383.         type: string
  384.       price:
  385.         type: number
  386.       maxUsers:
  387.         type: number
  388.       isClosed:
  389.         type: boolean
  390.       type:
  391.         type: string
  392.         enum:
  393.          [loto, toto]
  394.       games:
  395.         description: lottery games (in case the lottery is toto)
  396.         type: array
  397.         items:
  398.           type: object
  399.           properties:
  400.             gameId:
  401.               type: string
  402.             teamA:
  403.               type: string
  404.             teamB:
  405.               type: string
  406.             date:
  407.               type: string
  408.               format: date-time
  409.       endDate:
  410.         type: string
  411.         format: date-time
  412.       comission:
  413.         description: admin's comission
  414.         type: number
  415.       firstPercentage:
  416.         type: number
  417.       secondPercentage:
  418.         type: number
  419.       thirdPercentage:
  420.         type: number
  421.       result:
  422.         $ref: '#/definitions/lotteryResult'
  423.       password:
  424.         type: number
  425.       wins:
  426.         type: array
  427.         items:
  428.           type: object
  429.           properties:
  430.             betId:
  431.               type: string
  432.             place:
  433.               type: number
  434.               description: which place has this bet won (1/2/3)
  435.             split:
  436.               type: number
  437.               description: if multiple bets won at the same place this will tell between how many bets the prize has been split (1 if no other bets won)
  438.   newLottery:
  439.     properties:
  440.       name:
  441.         type: string
  442.       price:
  443.         type: number
  444.       maxUsers:
  445.         type: number
  446.       isClosed:
  447.         type: boolean
  448.       type:
  449.         type: string
  450.         enum:
  451.          [loto, toto]
  452.       games:
  453.         description: lottery games (in case the lottery is toto)
  454.         type: array
  455.         items:
  456.           type: object
  457.           properties:
  458.             gameId:
  459.               type: string
  460.             teamA:
  461.               type: string
  462.             teamB:
  463.               type: string
  464.             date:
  465.               type: string
  466.               format: date-time
  467.       endDate:
  468.         type: string
  469.         format: date-time
  470.       comission:
  471.         description: admin's comission
  472.         type: number
  473.       firstPercentage:
  474.         type: number
  475.       secondPercentage:
  476.         type: number
  477.       thirdPercentage:
  478.         type: number
  479.       result:
  480.         $ref: '#/definitions/lotteryResult'
  481.       password:
  482.         type: number
  483.  
  484.   bet:
  485.     required:
  486.      - userName
  487.       - lotteryId
  488.       - gamblerName
  489.       - betInfo
  490.     properties:
  491.       userName:
  492.         type: string
  493.       lotteryId:
  494.         type: string
  495.       gamblerName:
  496.         type: string
  497.       betInfo:
  498.         $ref: '#/definitions/betInfo'
  499.   newBet:
  500.     required:
  501.      - lotteryId
  502.       - gamblerName
  503.       - betInfo
  504.     properties:
  505.       lotteryId:
  506.         type: string
  507.       gamblerName:
  508.         type: string
  509.       betInfo:
  510.         $ref: '#/definitions/betInfo'
  511.   betInfo:
  512.     description: do not leave empty, fill either loto or toto
  513.     properties:
  514.       loto:
  515.         type: array
  516.         items:
  517.           type: number
  518.       toto:
  519.         type: array
  520.         items:
  521.           type: object
  522.           properties:
  523.             gameId:
  524.               type: number
  525.             guess:
  526.               description: 0 for tie, 1 for teamA, 2 for teamB
  527.               type: number
  528.   lotteryResult:
  529.     $ref: '#/definitions/betInfo'
  530.   lotteryIdAndResult:
  531.     properties:
  532.       lotteryId:
  533.         type: string
  534.       lotteryResult:
  535.         $ref: '#/definitions/lotteryResult'
  536.   wonBet:
  537.     description: a bet that has been won
  538.     properties:
  539.       betId:
  540.         type: string
  541.       lotteryId:
  542.         type: string
  543.       place:
  544.         type: number
  545.         description: which place has this bet won (1/2/3)
  546.       split:
  547.         type: number
  548.         description: if multiple bets won at the same place this will tell between how many bets the prize has been split (1 if no other bets won)
  549.   adminMessage:
  550.     properties:
  551.       text:
  552.         type: string
  553.       isModal:
  554.         type: boolean
  555.      
  556.   SuccessResponse:
  557.     required:
  558.       - message
  559.     properties:
  560.       message:
  561.         type: string
  562.   ErrorResponse:
  563.     required:
  564.      - message
  565.     properties:
  566.       message:
  567.         type: string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement