adorsys / adorsys/status-list-server

Align OpenAPI status contract & dual string/integer deserialization

未關閉
#480 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug high rust
主要語言
Rust
星號
22
分支
5
平均合併
2 天 6 小時
30 天內合併 PR
47

描述

## Objective

Resolve the contract mismatch between `docs/openapi.yaml` and `src/server/handlers/status_list/utils/request.rs` by supporting both string and integer status representations in serde and accurately documenting them.

## Context

In `docs/openapi.yaml`, `StatusValue` is documented as a string enum (`"VALID"`, `"INVALID"`, `"SUSPENDED"`). However, the serde deserializer in `src/server/handlers/status_list/utils/request.rs` only accepts numeric integers (`0`, `1`, `2`, `>=256`). When API clients generated from the OpenAPI specification send the documented string values (e.g. `{"index": 0, "status": "VALID"}`), the server rejects them with `HTTP 422 Unprocessable Entity`.

## Deliverables

- [ ] Update `Deserialize` for `Status` in `src/server/handlers/status_list/utils/request.rs` to accept:
- Numeric integers: `0` (VALID), `1` (INVALID), `2` (SUSPENDED), and `>=256` (ApplicationSpecific).
- String names (case-insensitive): `"VALID"` / `"valid"`, `"INVALID"` / `"invalid"`, `"SUSPENDED"` / `"suspended"`, and stringified integers (e.g. `"0"`).
- [ ] Update `docs/openapi.yaml` to document both formats using `oneOf` or a unified schema so client generators generate correct models.
- [ ] Add unit tests verifying successful deserialization of both string enum values and numeric values, and rejection of reserved integers (3..=255) and invalid strings.

## Acceptance Criteria

- [ ] `{"index": 0, "status": "VALID"}` and `{"index": 0, "status": 0}` are both accepted and deserialize to `Status::VALID`.
- [ ] OpenAPI specification matches server acceptance behavior.
- [ ] Standard OpenAPI-generated SDKs can publish and update status lists without deserialization errors.

## References

- `docs/openapi.yaml` (lines 560–565)
- `src/server/handlers/status_list/utils/request.rs` (lines 23–38)
- Arc review: `arc-review/finalReview/application-functional-bugs/README.md` (PoC 1)

貢獻指南

開啟貢獻指南

研究方向

Start in `src/server/handlers/status_list/utils/request.rs` (around lines 23–38) where `Status` deserialization is implemented, then inspect `docs/openapi.yaml` lines 560–565 for the current `StatusValue` schema. Update both so string names (case-insensitive and stringified integers) and numeric values `0/1/2/>=256` are accepted consistently. Add/extend unit tests for valid string/numeric statuses and invalid values (`3..=255`, bad strings), then run the relevant status-list serde tests with `cargo test`; done when both request formats deserialize correctly and the OpenAPI contract reflects that behavior.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
rust
領域
api, backend, documentation
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
活躍
描述清晰度
描述清楚
新手友好度
74/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。