Advertisement
madrahimov

Untitled

Nov 16th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.43 KB | None | 0 0
  1. # frozen_string_literal: true
  2.  
  3. require "rails_helper"
  4.  
  5. RSpec.configure do |config|
  6. # Specify a root folder where Swagger JSON files are generated
  7. # NOTE: If you're using the rswag-api to serve API descriptions, you'll need
  8. # to ensure that it's configured to serve Swagger from the same folder
  9. config.swagger_root = Rails.root.to_s + "/swagger"
  10.  
  11. # Define one or more Swagger documents and provide global metadata for each one
  12. # When you run the 'rswag:specs:to_swagger' rake task, the complete Swagger will
  13. # be generated at the provided relative path under swagger_root
  14. # By default, the operations defined in spec files are added to the first
  15. # document below. You can override this behavior by adding a swagger_doc tag to the
  16. # the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
  17. config.swagger_docs = {
  18. "v1/swagger.json" => {
  19. swagger: "2.0",
  20. info: {
  21. title: "Shop API V1",
  22. description: "https://shopcollabora.jowi.club/",
  23. version: "1.0",
  24. contact: {
  25. name: "API Support",
  26. email: "madrahimov.ilhom@gmail.com, emiralievlenur@gmail.com"
  27. }
  28. },
  29. tags: [
  30. {
  31. name: "Cities",
  32. description: "Countries And cities"
  33. },
  34. {
  35. name: "Registration",
  36. description: "User Registration"
  37. },
  38. {
  39. name: "Authorization",
  40. description: "User Authorization"
  41. },
  42. {
  43. name: "Reset Password",
  44. description: "User Reset Password"
  45. },
  46. {
  47. name: "Companies",
  48. description: "User Companies"
  49. },
  50. {
  51. name: "Currencies",
  52. description: "Currencies"
  53. },
  54. {
  55. name: "Shops",
  56. description: "Shops"
  57. },
  58. {
  59. name: "Categories",
  60. description: "Categories"
  61. },
  62. {
  63. name: "Tags",
  64. description: "Tags"
  65. },
  66. {
  67. name: "Stocks",
  68. description: "Stocks"
  69. },
  70. {
  71. name: "Settings Currencies",
  72. description: "Валюты магазина. Добавление/обновление через единый метод."
  73. },
  74. {
  75. name: "Settings Units",
  76. description: "Ед. измерения магазина. Включение и выключение через один метод."
  77. },
  78. {
  79. name: "Settings Taxes",
  80. description: "Налоги магазина. Если is_edit = false, то его нелья менять и удалять."
  81. }
  82. ],
  83. # host: "https://shopapi.jowi.club",
  84. # host: "localhost:3000",
  85. basePath: "/v1",
  86. securityDefinitions: {
  87. bearerAuth: {
  88. type: :apiKey,
  89. name: "Authorization",
  90. in: :header
  91. }
  92. },
  93. # schemes: ["http", "https"],
  94. consumes: "application/json",
  95. produces: "application/json",
  96.  
  97. definitions: {
  98. DefaultSuccessResponse: {
  99. required: [:success],
  100. type: :object,
  101. properties: {
  102. success: { type: :boolean, default: true }
  103. }
  104. },
  105. DefaultErrorResponse: {
  106. required: [:errors],
  107. type: :object,
  108. properties: {
  109. errors: {
  110. type: :array,
  111. items: {
  112. required: [:id, :code, :title],
  113. type: :object,
  114. properties: {
  115. id: { type: :string, format: :uuid },
  116. code: { type: :integer, format: :int32 },
  117. title: { type: :string }
  118. }
  119. }
  120. }
  121. }
  122. },
  123. CategoryObject: {
  124. required: [:id, :name, :children],
  125. type: :object,
  126. properties: {
  127. id: { type: :string, format: :uuid },
  128. name: { type: :string },
  129. children: {
  130. type: :array,
  131. items: {
  132. schema: {
  133. "$ref" => "#/definitions/CategoryObject"
  134. }
  135. }
  136. }
  137. }
  138. },
  139. TagObject: {
  140. required: [:id, :name, :is_active],
  141. type: :object,
  142. properties: {
  143. id: { type: :string, format: :uuid },
  144. name: { type: :string }
  145. }
  146. },
  147. StockObject: {
  148. required: [:id, :name, :country_id, :city_id, :address, :write_off_type],
  149. type: :object,
  150. properties: {
  151. id: { type: :string, format: :uuid },
  152. name: { type: :string },
  153. description: { type: :string },
  154. country_id: { type: :string, format: :uuid },
  155. city_id: { type: :string, format: :uuid },
  156. address: { type: :string },
  157. write_off_type: { type: :string }
  158. }
  159. },
  160. StockUserObject: {
  161. required: [:id, :first_name, :phone, :email],
  162. type: :object,
  163. properties: {
  164. id: { type: :string, format: :uuid },
  165. first_name: { type: :string },
  166. last_name: { type: :string },
  167. phone: { type: :string },
  168. email: { type: :string, format: :email }
  169. }
  170. },
  171. ProductObject: {
  172. required: [:id, :name, :unit_id, :shop_tax_id, :category_id, :cost_price, :markup, :price, :sku, :is_published, :disabe_price_block],
  173. type: :object,
  174. properties: {
  175. id: { type: :string, format: :uuid },
  176. name: { type: :string },
  177. text: { type: :string },
  178. unit_id: { type: :string, format: :uuid },
  179. shop_tax_id: { type: :string, format: :uuid },
  180. category_id: { type: :string, format: :uuid },
  181. cost_price: { type: :integer, format: :float },
  182. markup: { type: :integer, format: :float },
  183. price: { type: :integer, format: :float },
  184. sku: { type: :string },
  185. is_published: { type: :boolean },
  186. disabe_price_block: { type: :boolean }
  187. }
  188. },
  189. ProductTag: {
  190. required: [:id, :name],
  191. type: :object,
  192. properties: {
  193. id: { type: :string, format: :uuid },
  194. name: { type: :string }
  195. }
  196. },
  197. ProductVendorCode: {
  198. required: [:id, :vendor_code],
  199. type: :object,
  200. properties: {
  201. id: { type: :string, format: :uuid },
  202. vendor_code: { type: :string }
  203. }
  204. },
  205. ProductBarcode: {
  206. required: [:id, :barcode_type, :barcode],
  207. type: :object,
  208. properties: {
  209. id: { type: :string, format: :uuid },
  210. barcode_type: { type: :string },
  211. barcode: { type: :string }
  212. }
  213. },
  214. ProductPack: {
  215. required: [:id, :name, :count],
  216. type: :object,
  217. properties: {
  218. id: { type: :string, format: :uuid },
  219. name: { type: :string },
  220. count: { type: :integer, format: :int32 }
  221. }
  222. },
  223. ProductImage: {
  224. required: [:id, :name, :url, :position],
  225. type: :object,
  226. properties: {
  227. id: { type: :string, format: :uuid },
  228. name: { type: :string },
  229. url: { type: :string },
  230. position: { type: :integer, format: :int32 }
  231. }
  232. },
  233. ProductOptionType: {
  234. required: [:id, :product_option_type_values],
  235. type: :object,
  236. properties: {
  237. id: { type: :string, format: :uuid },
  238. product_option_type_values: {
  239. type: :array,
  240. items: {
  241. required: [:id, :name],
  242. type: :object,
  243. properties: {
  244. id: { type: :string, format: :uuid },
  245. name: { type: :string }
  246. }
  247. }
  248. }
  249. }
  250. },
  251. ProductVariant: {
  252. required: [:id, :cost_price, :markup, :price, :sku, :vendor_code, :is_published, :position, :by_price_list, :variant_option_type_values, :variant_images],
  253. type: :object,
  254. properties: {
  255. id: { type: :string, format: :uuid },
  256. cost_price: { type: :integer, format: :float },
  257. markup: { type: :integer, format: :float },
  258. price: { type: :integer, format: :int32 },
  259. sku: { type: :string },
  260. vendor_code: { type: :string },
  261. is_published: { type: :boolean },
  262. position: { type: :integer, format: :int32 },
  263. by_price_list: { type: :boolean },
  264. variant_option_type_values: {
  265. type: :array,
  266. items: {
  267. required: [:id, :name, :option_type_id],
  268. type: :object,
  269. properties: {
  270. id: { type: :string, format: :uuid },
  271. name: { type: :string },
  272. option_type_id: { type: :string, format: :uuid }
  273. }
  274. }
  275. },
  276. variant_images: {
  277. type: :array,
  278. items: {
  279. required: [:id, :name, :url, :position],
  280. type: :object,
  281. properties: {
  282. id: { type: :string, format: :uuid },
  283. name: { type: :string },
  284. url: { type: :string },
  285. position: { type: :integer, format: :int32 }
  286. }
  287. }
  288. }
  289. }
  290. },
  291. DocumentObject: {
  292. type: :object,
  293. required: [:type, :date, :stock_id, :currency_id, :shop_id],
  294. properties: {
  295. type: { type: :string },
  296. date: { type: :date },
  297. document_date: { type: :date },
  298. invoice_date: { type: :date },
  299. document_number: { type: :string },
  300. invoice_number: { type: :string },
  301. status: { type: :string },
  302. additional_cost: { type: :float },
  303. note: { type: :string },
  304. stock_id: { type: :string, format: :uuid },
  305. currency_id: { type: :string, format: :uuid },
  306. shop_id: { type: :string, format: :uuid }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement