fix(api): Decimal-параметр ребалансировки ломал генерацию Dart-клиента
cash_available был bare Decimal | None в Query(...) — pydantic отдаёт для Decimal anyOf[number, pattern-string], который openapi-generator не умеет свернуть в один тип и вместо этого синтезирует пустой класс CashAvailable без полей (синтаксически битый .dart, компиляция всего пакета падает). Остальные Decimal-поля в API давно оборачиваются в Money/MoneyOpt (api/schemas/common.py) ровно за счёт этого — anyOf[string, null] генератор понимает. cash_available обошёл соглашение, потому что это единственный Decimal-параметр запроса во всём API, а не тело ответа.
This commit is contained in:
@@ -21,7 +21,6 @@ doc/BenchmarksApi.md
|
||||
doc/Broker.md
|
||||
doc/CalendarEntry.md
|
||||
doc/CalendarOut.md
|
||||
doc/CashAvailable.md
|
||||
doc/CashFlowBrokerMonth.md
|
||||
doc/CashFlowMonth.md
|
||||
doc/CashflowApi.md
|
||||
@@ -166,7 +165,6 @@ lib/src/model/benchmark_return_out.dart
|
||||
lib/src/model/broker.dart
|
||||
lib/src/model/calendar_entry.dart
|
||||
lib/src/model/calendar_out.dart
|
||||
lib/src/model/cash_available.dart
|
||||
lib/src/model/cash_flow_broker_month.dart
|
||||
lib/src/model/cash_flow_month.dart
|
||||
lib/src/model/category_out.dart
|
||||
@@ -251,47 +249,3 @@ lib/src/model/unmatched_zm_out.dart
|
||||
lib/src/model/user_out.dart
|
||||
lib/src/model/value_day.dart
|
||||
pubspec.yaml
|
||||
test/benchmark_comparison_out_test.dart
|
||||
test/benchmark_comparison_test.dart
|
||||
test/benchmark_create_test.dart
|
||||
test/benchmark_out_test.dart
|
||||
test/benchmark_patch_test.dart
|
||||
test/benchmark_return_out_test.dart
|
||||
test/benchmarks_api_test.dart
|
||||
test/calendar_entry_test.dart
|
||||
test/calendar_out_test.dart
|
||||
test/cash_available_test.dart
|
||||
test/cash_flow_broker_month_test.dart
|
||||
test/forecast_month_test.dart
|
||||
test/forecast_out_test.dart
|
||||
test/goal_create_test.dart
|
||||
test/goal_out_test.dart
|
||||
test/goal_patch_test.dart
|
||||
test/goal_progress_out_test.dart
|
||||
test/goals_api_test.dart
|
||||
test/history_out_test.dart
|
||||
test/history_row_test.dart
|
||||
test/history_totals_test.dart
|
||||
test/income_api_test.dart
|
||||
test/link_create_test.dart
|
||||
test/link_out_test.dart
|
||||
test/links_api_test.dart
|
||||
test/price_manual_in_test.dart
|
||||
test/price_manual_out_test.dart
|
||||
test/rebalance_api_test.dart
|
||||
test/rebalance_bucket_out_test.dart
|
||||
test/rebalance_out_test.dart
|
||||
test/target_in_test.dart
|
||||
test/target_out_test.dart
|
||||
test/targets_in_test.dart
|
||||
test/targets_out_test.dart
|
||||
test/tax_account_out_test.dart
|
||||
test/tax_api_test.dart
|
||||
test/tax_lot_out_test.dart
|
||||
test/tax_lots_out_test.dart
|
||||
test/tax_totals_test.dart
|
||||
test/tax_year_out_test.dart
|
||||
test/trade_out_test.dart
|
||||
test/unmatched_broker_out_test.dart
|
||||
test/unmatched_out_test.dart
|
||||
test/unmatched_zm_out_test.dart
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# fintracker_api.model.CashAvailable
|
||||
|
||||
## Load the model package
|
||||
```dart
|
||||
import 'package:fintracker_api/api.dart';
|
||||
```
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import 'package:fintracker_api/api.dart';
|
||||
final api = FintrackerApi().getRebalanceApi();
|
||||
final int portfolioId = 56; // int |
|
||||
final String dimension = dimension_example; // String | asset_class | sector | country | currency
|
||||
final CashAvailable cashAvailable = ; // CashAvailable | переопределяет остаток на счетах для what-if
|
||||
final String cashAvailable = cashAvailable_example; // String | переопределяет остаток на счетах для what-if
|
||||
|
||||
try {
|
||||
final response = api.rebalanceRebalance(portfolioId, dimension, cashAvailable);
|
||||
@@ -42,7 +42,7 @@ Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**portfolioId** | **int**| |
|
||||
**dimension** | **String**| asset_class | sector | country | currency | [optional] [default to 'asset_class']
|
||||
**cashAvailable** | [**CashAvailable**](.md)| переопределяет остаток на счетах для what-if | [optional]
|
||||
**cashAvailable** | **String**| переопределяет остаток на счетах для what-if | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ export 'package:fintracker_api/src/model/benchmark_return_out.dart';
|
||||
export 'package:fintracker_api/src/model/broker.dart';
|
||||
export 'package:fintracker_api/src/model/calendar_entry.dart';
|
||||
export 'package:fintracker_api/src/model/calendar_out.dart';
|
||||
export 'package:fintracker_api/src/model/cash_available.dart';
|
||||
export 'package:fintracker_api/src/model/cash_flow_broker_month.dart';
|
||||
export 'package:fintracker_api/src/model/cash_flow_month.dart';
|
||||
export 'package:fintracker_api/src/model/category_out.dart';
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'dart:convert';
|
||||
import 'package:fintracker_api/src/deserialize.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import 'package:fintracker_api/src/model/cash_available.dart';
|
||||
import 'package:fintracker_api/src/model/problem.dart';
|
||||
import 'package:fintracker_api/src/model/rebalance_out.dart';
|
||||
import 'package:fintracker_api/src/model/targets_in.dart';
|
||||
@@ -40,7 +39,7 @@ class RebalanceApi {
|
||||
Future<Response<RebalanceOut>> rebalanceRebalance({
|
||||
required int portfolioId,
|
||||
String? dimension = 'asset_class',
|
||||
CashAvailable? cashAvailable,
|
||||
String? cashAvailable,
|
||||
CancelToken? cancelToken,
|
||||
Map<String, dynamic>? headers,
|
||||
Map<String, dynamic>? extra,
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:fintracker_api/src/model/benchmark_patch.dart';
|
||||
import 'package:fintracker_api/src/model/benchmark_return_out.dart';
|
||||
import 'package:fintracker_api/src/model/calendar_entry.dart';
|
||||
import 'package:fintracker_api/src/model/calendar_out.dart';
|
||||
import 'package:fintracker_api/src/model/cash_available.dart';
|
||||
import 'package:fintracker_api/src/model/cash_flow_broker_month.dart';
|
||||
import 'package:fintracker_api/src/model/cash_flow_month.dart';
|
||||
import 'package:fintracker_api/src/model/category_out.dart';
|
||||
@@ -144,8 +143,6 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||
return CalendarEntry.fromJson(value as Map<String, dynamic>) as ReturnType;
|
||||
case 'CalendarOut':
|
||||
return CalendarOut.fromJson(value as Map<String, dynamic>) as ReturnType;
|
||||
case 'CashAvailable':
|
||||
return CashAvailable.fromJson(value as Map<String, dynamic>) as ReturnType;
|
||||
case 'CashFlowBrokerMonth':
|
||||
return CashFlowBrokerMonth.fromJson(value as Map<String, dynamic>) as ReturnType;
|
||||
case 'CashFlowMonth':
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
|
||||
// ignore_for_file: unused_element
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'cash_available.g.dart';
|
||||
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(
|
||||
checked: true,
|
||||
createToJson: true,
|
||||
disallowUnrecognizedKeys: false,
|
||||
explicitToJson: true,
|
||||
)
|
||||
class CashAvailable {
|
||||
/// Returns a new [CashAvailable] instance.
|
||||
CashAvailable({
|
||||
});
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is CashAvailable &&
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
|
||||
factory CashAvailable.fromJson(Map<String, dynamic> json) => _$CashAvailableFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CashAvailableToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:fintracker_api/fintracker_api.dart';
|
||||
|
||||
// tests for CashAvailable
|
||||
void main() {
|
||||
final CashAvailable? instance = /* CashAvailable(...) */ null;
|
||||
// TODO add properties to the entity
|
||||
|
||||
group(CashAvailable, () {
|
||||
});
|
||||
}
|
||||
@@ -21,6 +21,7 @@ from sqlalchemy import delete, select
|
||||
from fintracker.analytics.rebalance import DEFAULT_DIMENSION, compute_rebalance
|
||||
from fintracker.api.deps import CurrentUser, SessionDep
|
||||
from fintracker.api.errors import Problem
|
||||
from fintracker.api.schemas.common import MoneyOpt
|
||||
from fintracker.api.schemas.rebalance import (
|
||||
RebalanceBucketOut,
|
||||
RebalanceOut,
|
||||
@@ -180,7 +181,7 @@ async def get_rebalance(
|
||||
_: CurrentUser,
|
||||
dimension: DimensionParam = DEFAULT_DIMENSION.value,
|
||||
cash_available: Annotated[
|
||||
Decimal | None, Query(description="переопределяет остаток на счетах для what-if")
|
||||
MoneyOpt, Query(description="переопределяет остаток на счетах для what-if")
|
||||
] = None,
|
||||
) -> RebalanceOut:
|
||||
await _portfolio(session, portfolio_id)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user