madrahimov

Untitled

Nov 16th, 2018
239
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. }
  27. },
  28. tags: [
  29. {
  30. name: "Cities",
  31. description: "Countries And cities"
  32. },
  33. {
  34. name: "Registration",
  35. description: "User Registration"
  36. },
  37. {
  38. name: "Authorization",
  39. description: "User Authorization"
  40. },
  41. {
  42. name: "Reset Password",
  43. description: "User Reset Password"
  44. },
  45. {
  46. name: "Companies",
  47. description: "User Companies"
  48. },
  49. {
  50. name: "Currencies",
  51. description: "Currencies"
  52. },
  53. {
  54. name: "Shops",
  55. description: "Shops"
  56. },
  57. {
  58. name: "Categories",
  59. description: "Categories"
  60. },
  61. {
  62. name: "Tags",
  63. description: "Tags"
  64. },
  65. {
  66. name: "Stocks",
  67. description: "Stocks"
  68. },
  69. {
  70. name: "Settings Currencies",
  71. description: "Валюты магазина. Добавление/обновление через единый метод."
  72. },
  73. {
  74. name: "Settings Units",
  75. description: "Ед. измерения магазина. Включение и выключение через один метод."
  76. },
  77. {
  78. name: "Settings Taxes",
  79. description: "Налоги магазина. Если is_edit = false, то его нелья менять и удалять."
  80. }
  81. ],
  82. # host: "https://shopapi.jowi.club",
  83. # host: "localhost:3000",
  84. basePath: "/v1",
  85. securityDefinitions: {
  86. bearerAuth: {
  87. type: :apiKey,
  88. name: "Authorization",
  89. in: :header
  90. }
  91. },
  92. # schemes: ["http", "https"],
  93. consumes: "application/json",
  94. produces: "application/json",
  95.  
  96. definitions: {
  97. DefaultSuccessResponse: {
  98. required: [:success],
  99. type: :object,
  100. properties: {
  101. success: { type: :boolean, default: true }
  102. }
  103. },
  104. DefaultErrorResponse: {
  105. required: [:errors],
  106. type: :object,
  107. properties: {
  108. errors: {
  109. type: :array,
  110. items: {
  111. required: [:id, :code, :title],
  112. type: :object,
  113. properties: {
  114. id: { type: :string, format: :uuid },
  115. code: { type: :integer, format: :int32 },
  116. title: { type: :string }
  117. }
  118. }
  119. }
  120. }
  121. },
  122. CategoryObject: {
  123. required: [:id, :name, :children],
  124. type: :object,
  125. properties: {
  126. id: { type: :string, format: :uuid },
  127. name: { type: :string },
  128. children: {
  129. type: :array,
  130. items: {
  131. schema: {
  132. "$ref" => "#/definitions/CategoryObject"
  133. }
  134. }
  135. }
  136. }
  137. },
  138. TagObject: {
  139. required: [:id, :name, :is_active],
  140. type: :object,
  141. properties: {
  142. id: { type: :string, format: :uuid },
  143. name: { type: :string }
  144. }
  145. },
  146. StockObject: {
  147. required: [:id, :name, :country_id, :city_id, :address, :write_off_type],
  148. type: :object,
  149. properties: {
  150. id: { type: :string, format: :uuid },
  151. name: { type: :string },
  152. description: { type: :string },
  153. country_id: { type: :string, format: :uuid },
  154. city_id: { type: :string, format: :uuid },
  155. address: { type: :string },
  156. write_off_type: { type: :string }
  157. }
  158. },
  159. StockUserObject: {
  160. required: [:id, :first_name, :phone, :email],
  161. type: :object,
  162. properties: {
  163. id: { type: :string, format: :uuid },
  164. first_name: { type: :string },
  165. last_name: { type: :string },
  166. phone: { type: :string },
  167. email: { type: :string, format: :email }
  168. }
  169. },
  170. ProductObject: {
  171. required: [:id, :name, :unit_id, :shop_tax_id, :category_id, :cost_price, :markup, :price, :sku, :is_published, :disabe_price_block],
  172. type: :object,
  173. properties: {
  174. id: { type: :string, format: :uuid },
  175. name: { type: :string },
  176. text: { type: :string },
  177. unit_id: { type: :string, format: :uuid },
  178. shop_tax_id: { type: :string, format: :uuid },
  179. category_id: { type: :string, format: :uuid },
  180. cost_price: { type: :integer, format: :float },
  181. markup: { type: :integer, format: :float },
  182. price: { type: :integer, format: :float },
  183. sku: { type: :string },
  184. is_published: { type: :boolean },
  185. disabe_price_block: { type: :boolean }
  186. }
  187. },
  188. ProductTag: {
  189. required: [:id, :name],
  190. type: :object,
  191. properties: {
  192. id: { type: :string, format: :uuid },
  193. name: { type: :string }
  194. }
  195. },
  196. ProductVendorCode: {
  197. required: [:id, :vendor_code],
  198. type: :object,
  199. properties: {
  200. id: { type: :string, format: :uuid },
  201. vendor_code: { type: :string }
  202. }
  203. },
  204. ProductBarcode: {
  205. required: [:id, :barcode_type, :barcode],
  206. type: :object,
  207. properties: {
  208. id: { type: :string, format: :uuid },
  209. barcode_type: { type: :string },
  210. barcode: { type: :string }
  211. }
  212. },
  213. ProductPack: {
  214. required: [:id, :name, :count],
  215. type: :object,
  216. properties: {
  217. id: { type: :string, format: :uuid },
  218. name: { type: :string },
  219. count: { type: :integer, format: :int32 }
  220. }
  221. },
  222. ProductImage: {
  223. required: [:id, :name, :url, :position],
  224. type: :object,
  225. properties: {
  226. id: { type: :string, format: :uuid },
  227. name: { type: :string },
  228. url: { type: :string },
  229. position: { type: :integer, format: :int32 }
  230. }
  231. },
  232. ProductOptionType: {
  233. required: [:id, :product_option_type_values],
  234. type: :object,
  235. properties: {
  236. id: { type: :string, format: :uuid },
  237. product_option_type_values: {
  238. type: :array,
  239. items: {
  240. required: [:id, :name],
  241. type: :object,
  242. properties: {
  243. id: { type: :string, format: :uuid },
  244. name: { type: :string }
  245. }
  246. }
  247. }
  248. }
  249. },
  250. ProductVariant: {
  251. required: [:id, :cost_price, :markup, :price, :sku, :vendor_code, :is_published, :position, :by_price_list, :variant_option_type_values, :variant_images],
  252. type: :object,
  253. properties: {
  254. id: { type: :string, format: :uuid },
  255. cost_price: { type: :integer, format: :float },
  256. markup: { type: :integer, format: :float },
  257. price: { type: :integer, format: :int32 },
  258. sku: { type: :string },
  259. vendor_code: { type: :string },
  260. is_published: { type: :boolean },
  261. position: { type: :integer, format: :int32 },
  262. by_price_list: { type: :boolean },
  263. variant_option_type_values: {
  264. type: :array,
  265. items: {
  266. required: [:id, :name, :option_type_id],
  267. type: :object,
  268. properties: {
  269. id: { type: :string, format: :uuid },
  270. name: { type: :string },
  271. option_type_id: { type: :string, format: :uuid }
  272. }
  273. }
  274. },
  275. variant_images: {
  276. type: :array,
  277. items: {
  278. required: [:id, :name, :url, :position],
  279. type: :object,
  280. properties: {
  281. id: { type: :string, format: :uuid },
  282. name: { type: :string },
  283. url: { type: :string },
  284. position: { type: :integer, format: :int32 }
  285. }
  286. }
  287. }
  288. }
  289. },
  290. DocumentObject: {
  291. type: :object,
  292. required: [:type, :date, :stock_id, :currency_id, :shop_id],
  293. properties: {
  294. type: { type: :string },
  295. date: { type: :date },
  296. document_date: { type: :date },
  297. invoice_date: { type: :date },
  298. document_number: { type: :string },
  299. invoice_number: { type: :string },
  300. status: { type: :string },
  301. additional_cost: { type: :float },
  302. note: { type: :string },
  303. stock_id: { type: :string, format: :uuid },
  304. currency_id: { type: :string, format: :uuid },
  305. shop_id: { type: :string, format: :uuid }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. end
Advertisement
Add Comment
Please, Sign In to add comment