RustRover cargo-generate template: Axum + Vue 3 + TypeScript + Tailwind + sqlx
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.
 
 
 
 
 
 

459 rivejä
10 KiB

  1. {
  2. "openapi": "3.1.0",
  3. "info": {
  4. "title": "rust-template",
  5. "description": "Axum API server",
  6. "license": {
  7. "name": "MIT",
  8. "identifier": "MIT"
  9. },
  10. "version": "0.1.0"
  11. },
  12. "paths": {
  13. "/api/v1/items": {
  14. "get": {
  15. "tags": [
  16. "items"
  17. ],
  18. "summary": "List items, newest first.",
  19. "operationId": "list_items",
  20. "parameters": [
  21. {
  22. "name": "page",
  23. "in": "query",
  24. "description": "1-based page index.",
  25. "required": false,
  26. "schema": {
  27. "type": "integer",
  28. "format": "int32",
  29. "minimum": 0
  30. }
  31. },
  32. {
  33. "name": "per_page",
  34. "in": "query",
  35. "description": "Page size (max 100).",
  36. "required": false,
  37. "schema": {
  38. "type": "integer",
  39. "format": "int32",
  40. "minimum": 0
  41. }
  42. }
  43. ],
  44. "responses": {
  45. "200": {
  46. "description": "Paged item list",
  47. "content": {
  48. "application/json": {
  49. "schema": {
  50. "$ref": "#/components/schemas/ItemPage"
  51. }
  52. }
  53. }
  54. }
  55. }
  56. },
  57. "post": {
  58. "tags": [
  59. "items"
  60. ],
  61. "summary": "Create an item.",
  62. "operationId": "create_item",
  63. "requestBody": {
  64. "content": {
  65. "application/json": {
  66. "schema": {
  67. "$ref": "#/components/schemas/CreateItemRequest"
  68. }
  69. }
  70. },
  71. "required": true
  72. },
  73. "responses": {
  74. "201": {
  75. "description": "Created item",
  76. "content": {
  77. "application/json": {
  78. "schema": {
  79. "$ref": "#/components/schemas/ItemResponse"
  80. }
  81. }
  82. }
  83. },
  84. "400": {
  85. "description": "Validation error",
  86. "content": {
  87. "application/json": {
  88. "schema": {
  89. "$ref": "#/components/schemas/ErrorBody"
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. },
  97. "/api/v1/items/{id}": {
  98. "get": {
  99. "tags": [
  100. "items"
  101. ],
  102. "summary": "Fetch a single item.",
  103. "operationId": "get_item",
  104. "parameters": [
  105. {
  106. "name": "id",
  107. "in": "path",
  108. "description": "Item id",
  109. "required": true,
  110. "schema": {
  111. "type": "string",
  112. "format": "uuid"
  113. }
  114. }
  115. ],
  116. "responses": {
  117. "200": {
  118. "description": "Item",
  119. "content": {
  120. "application/json": {
  121. "schema": {
  122. "$ref": "#/components/schemas/ItemResponse"
  123. }
  124. }
  125. }
  126. },
  127. "404": {
  128. "description": "Missing item",
  129. "content": {
  130. "application/json": {
  131. "schema": {
  132. "$ref": "#/components/schemas/ErrorBody"
  133. }
  134. }
  135. }
  136. }
  137. }
  138. },
  139. "delete": {
  140. "tags": [
  141. "items"
  142. ],
  143. "summary": "Delete an item.",
  144. "operationId": "delete_item",
  145. "parameters": [
  146. {
  147. "name": "id",
  148. "in": "path",
  149. "description": "Item id",
  150. "required": true,
  151. "schema": {
  152. "type": "string",
  153. "format": "uuid"
  154. }
  155. }
  156. ],
  157. "responses": {
  158. "204": {
  159. "description": "Deleted"
  160. },
  161. "404": {
  162. "description": "Missing item",
  163. "content": {
  164. "application/json": {
  165. "schema": {
  166. "$ref": "#/components/schemas/ErrorBody"
  167. }
  168. }
  169. }
  170. }
  171. }
  172. },
  173. "patch": {
  174. "tags": [
  175. "items"
  176. ],
  177. "summary": "Replace selected item fields.",
  178. "operationId": "update_item",
  179. "parameters": [
  180. {
  181. "name": "id",
  182. "in": "path",
  183. "description": "Item id",
  184. "required": true,
  185. "schema": {
  186. "type": "string",
  187. "format": "uuid"
  188. }
  189. }
  190. ],
  191. "requestBody": {
  192. "content": {
  193. "application/json": {
  194. "schema": {
  195. "$ref": "#/components/schemas/UpdateItemRequest"
  196. }
  197. }
  198. },
  199. "required": true
  200. },
  201. "responses": {
  202. "200": {
  203. "description": "Updated item",
  204. "content": {
  205. "application/json": {
  206. "schema": {
  207. "$ref": "#/components/schemas/ItemResponse"
  208. }
  209. }
  210. }
  211. },
  212. "404": {
  213. "description": "Missing item",
  214. "content": {
  215. "application/json": {
  216. "schema": {
  217. "$ref": "#/components/schemas/ErrorBody"
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }
  224. },
  225. "/health/live": {
  226. "get": {
  227. "tags": [
  228. "health"
  229. ],
  230. "summary": "Liveness probe. Process is up.",
  231. "operationId": "live",
  232. "responses": {
  233. "200": {
  234. "description": "Process is running",
  235. "content": {
  236. "application/json": {
  237. "schema": {
  238. "$ref": "#/components/schemas/HealthResponse"
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. },
  246. "/health/ready": {
  247. "get": {
  248. "tags": [
  249. "health"
  250. ],
  251. "summary": "Readiness probe. Database is reachable.",
  252. "operationId": "ready",
  253. "responses": {
  254. "200": {
  255. "description": "Database is reachable",
  256. "content": {
  257. "application/json": {
  258. "schema": {
  259. "$ref": "#/components/schemas/ReadyResponse"
  260. }
  261. }
  262. }
  263. },
  264. "500": {
  265. "description": "Database is unreachable",
  266. "content": {
  267. "application/json": {
  268. "schema": {
  269. "$ref": "#/components/schemas/ErrorBody"
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. },
  278. "components": {
  279. "schemas": {
  280. "CreateItemRequest": {
  281. "type": "object",
  282. "required": [
  283. "name"
  284. ],
  285. "properties": {
  286. "description": {
  287. "type": [
  288. "string",
  289. "null"
  290. ]
  291. },
  292. "name": {
  293. "type": "string"
  294. }
  295. }
  296. },
  297. "ErrorBody": {
  298. "type": "object",
  299. "description": "Stable JSON error envelope returned by every handler.",
  300. "required": [
  301. "error"
  302. ],
  303. "properties": {
  304. "error": {
  305. "$ref": "#/components/schemas/ErrorDetail"
  306. }
  307. }
  308. },
  309. "ErrorDetail": {
  310. "type": "object",
  311. "required": [
  312. "status",
  313. "code",
  314. "message"
  315. ],
  316. "properties": {
  317. "code": {
  318. "type": "string"
  319. },
  320. "message": {
  321. "type": "string"
  322. },
  323. "status": {
  324. "type": "integer",
  325. "format": "int32",
  326. "minimum": 0
  327. },
  328. "trace_id": {
  329. "type": [
  330. "string",
  331. "null"
  332. ]
  333. }
  334. }
  335. },
  336. "HealthResponse": {
  337. "type": "object",
  338. "required": [
  339. "status",
  340. "service"
  341. ],
  342. "properties": {
  343. "service": {
  344. "type": "string"
  345. },
  346. "status": {
  347. "type": "string"
  348. }
  349. }
  350. },
  351. "ItemPage": {
  352. "type": "object",
  353. "required": [
  354. "items",
  355. "page",
  356. "per_page",
  357. "total"
  358. ],
  359. "properties": {
  360. "items": {
  361. "type": "array",
  362. "items": {
  363. "$ref": "#/components/schemas/ItemResponse"
  364. }
  365. },
  366. "page": {
  367. "type": "integer",
  368. "format": "int32",
  369. "minimum": 0
  370. },
  371. "per_page": {
  372. "type": "integer",
  373. "format": "int32",
  374. "minimum": 0
  375. },
  376. "total": {
  377. "type": "integer",
  378. "format": "int64"
  379. }
  380. }
  381. },
  382. "ItemResponse": {
  383. "type": "object",
  384. "required": [
  385. "id",
  386. "name",
  387. "created_at",
  388. "updated_at"
  389. ],
  390. "properties": {
  391. "created_at": {
  392. "type": "string",
  393. "format": "date-time"
  394. },
  395. "description": {
  396. "type": [
  397. "string",
  398. "null"
  399. ]
  400. },
  401. "id": {
  402. "type": "string",
  403. "format": "uuid"
  404. },
  405. "name": {
  406. "type": "string"
  407. },
  408. "updated_at": {
  409. "type": "string",
  410. "format": "date-time"
  411. }
  412. }
  413. },
  414. "ReadyResponse": {
  415. "type": "object",
  416. "required": [
  417. "status",
  418. "database"
  419. ],
  420. "properties": {
  421. "database": {
  422. "type": "string"
  423. },
  424. "status": {
  425. "type": "string"
  426. }
  427. }
  428. },
  429. "UpdateItemRequest": {
  430. "type": "object",
  431. "properties": {
  432. "description": {
  433. "type": [
  434. "string",
  435. "null"
  436. ]
  437. },
  438. "name": {
  439. "type": [
  440. "string",
  441. "null"
  442. ]
  443. }
  444. }
  445. }
  446. }
  447. },
  448. "tags": [
  449. {
  450. "name": "health",
  451. "description": "Liveness and readiness"
  452. },
  453. {
  454. "name": "items",
  455. "description": "Example CRUD resource"
  456. }
  457. ]
  458. }