feat(web-api): единый контракт ошибок и HTTP-статусов - #583
Open
Ibochkarev wants to merge 5 commits into
Open
Conversation
Сохраняем envelope #341 и добавляем machine error_code, чтобы Nuxt получал стабильные 401/404/422/429 и field errors без getData()-потери status.
Intelephense читал `@return Response ['…']` как array и ругался на Response::error.
Имя error() совпадало с Response::error и давало ложный Expected array в IDE.
Убирает ложный Expected array у return Response::error в IDE.
Убирает transformResponse в OrderController, из‑за которого IDE видела return array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Единый success/error envelope Web API
/api/v1для TypeScript/Nuxt: HTTP status больше не теряется через->getData(), field errors живут в top-levelerrors, additiveerror_code(snake_case).Envelope
#341сохранён. Nested{ error: {…} }не вводим.Ключевые изменения
ApiErrorCode+Response::error/errorWithCode/fromProcessorсerror_codeResponse(create address → HTTP 201)errors+ HTTP 422 + зеркалоdata.errors(BC)existing_idвdata; list →{items, total}items(=orders)DomainMs2Responseподнимает field map вerrors/422,_nf→ 404, иначеbusiness_ruletoken_expired/token_invalid/rate_limited; mint fail → 500/internal_errorТип изменений
Связанные Issues
Closes #572
Как это было протестировано?
composer ci:php,composer stan)Конфигурация тестирования:
feat/issue-572-web-api-error-contractЧеклист
Wire contract (кратко)
Success:
{ success, message, data }— без изменений ключей.Дополнительные заметки
dataбыл голым массивом →{items,total}(breaking для клиентов сArray.isArray(data)).errors.existing_id→data.existing_id.token_*.