fix: add ProducesResponseType to controllers, regenerate openapi.json
This commit is contained in:
parent
3c7db7092c
commit
40b256b870
@ -16,6 +16,8 @@ public class AuthController : ControllerBase
|
||||
=> _credentials = credentials;
|
||||
|
||||
[HttpPost("login")]
|
||||
[ProducesResponseType(typeof(LoginResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
public IActionResult Login([FromBody] LoginRequest request)
|
||||
{
|
||||
if (request.Username != _credentials.Username
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using AccountTracking.Api.Models.Dtos;
|
||||
using AccountTracking.Api.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -13,18 +14,22 @@ public class DashboardController : ControllerBase
|
||||
public DashboardController(DashboardService svc) => _svc = svc;
|
||||
|
||||
[HttpGet("summary")]
|
||||
[ProducesResponseType(typeof(SummaryDto), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Summary([FromQuery] int year, [FromQuery] int? month)
|
||||
=> Ok(await _svc.GetSummaryAsync(year, month));
|
||||
|
||||
[HttpGet("spending-by-category")]
|
||||
[ProducesResponseType(typeof(List<CategorySpendingDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> SpendingByCategory([FromQuery] int year, [FromQuery] int? month)
|
||||
=> Ok(await _svc.GetSpendingByCategoryAsync(year, month));
|
||||
|
||||
[HttpGet("monthly-balances")]
|
||||
[ProducesResponseType(typeof(List<MonthlyBalanceDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> MonthlyBalances([FromQuery] int year)
|
||||
=> Ok(await _svc.GetMonthlyBalancesAsync(year));
|
||||
|
||||
[HttpGet("cumulative-spending")]
|
||||
[ProducesResponseType(typeof(List<CumulativeSpendingDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> CumulativeSpending([FromQuery] int year, [FromQuery] int month)
|
||||
=> Ok(await _svc.GetCumulativeSpendingAsync(year, month));
|
||||
}
|
||||
|
||||
@ -22,6 +22,8 @@ public class TransactionsController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("import")]
|
||||
[ProducesResponseType(typeof(ImportResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ErrorResult), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> Import(IFormFile file)
|
||||
{
|
||||
if (file == null || file.Length == 0)
|
||||
@ -40,6 +42,7 @@ public class TransactionsController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(TransactionListResponse), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> List(
|
||||
[FromQuery] int year,
|
||||
[FromQuery] int? month,
|
||||
@ -78,6 +81,7 @@ public class TransactionsController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("categories")]
|
||||
[ProducesResponseType(typeof(string[]), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> Categories()
|
||||
{
|
||||
var cats = await _db.Transactions
|
||||
|
||||
@ -33,10 +33,19 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"$ref": "#/components/schemas/LoginResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,10 +84,9 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"$ref": "#/components/schemas/SummaryDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,10 +125,12 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CategorySpendingDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,10 +159,12 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/MonthlyBalanceDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,10 +202,12 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CumulativeSpendingDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,10 +241,19 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"$ref": "#/components/schemas/ImportResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ErrorResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -307,10 +330,9 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"$ref": "#/components/schemas/TransactionListResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,10 +350,12 @@
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/octet-stream": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -342,6 +366,47 @@
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"LoginResponse": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ProblemDetails": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"nullable": true
|
||||
},
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"nullable": true
|
||||
},
|
||||
"detail": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"instance": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"LoginRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@ -353,6 +418,142 @@
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SummaryDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"totalSpent": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
},
|
||||
"totalIncome": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CategorySpendingDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"category": {
|
||||
"type": "string"
|
||||
},
|
||||
"total": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MonthlyBalanceDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"month": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"closingBalance": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CumulativeSpendingDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"day": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"cumulativeSpent": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ImportResult": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"recordsImported": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"recordsSkipped": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ErrorResult": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"TransactionListResponse": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/TransactionDto"
|
||||
}
|
||||
},
|
||||
"totalCount": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"page": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"TransactionDto": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"bookingDate": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"counterPartyName": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"category": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"amount": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
},
|
||||
"balance": {
|
||||
"type": "number",
|
||||
"format": "decimal"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user