feat(api): define public problem errors, pagination, and retry contract
This commit is contained in:
1 parent
b2f6e87bfe
commit
565ca94bbb
86 files changed
+8200
-154
No files matched your search
+4
-1
@@ -30,15 +30,18 @@ lint: bundle ## Lint both bundled contracts
|
||||
.PHONY: check
|
||||
check: lint ## Build and lint both contract bundles
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_merge_schemas.py'
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_contract_copies.py'
|
||||
|
||||
.PHONY: check-compat
|
||||
check-compat: bundle ## Compare the public contract with API_BASE_REF
|
||||
API_BASE_REF="$(API_BASE_REF)" REDOCLY="$(REDOCLY)" CODEGEN_PYTHON="$(CODEGEN_PYTHON)" bash "$(ROOT_DIR)/scripts/check-api-compat.sh"
|
||||
|
||||
.PHONY: check-toolchain
|
||||
check-toolchain: ## Check OpenAPI 3.2.0 support and generated validation behavior
|
||||
check-toolchain: ## Check OpenAPI 3.2.0 support with ogen, Orval, and Pydantic on the compatibility fixture
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/testdata/openapi-3.2.0.yml"
|
||||
$(MAKE) -C "$(ROOT_DIR)/backend" check-ogen-compat
|
||||
$(MAKE) -C "$(ROOT_DIR)/frontend" check-orval-compat
|
||||
$(MAKE) -C "$(ROOT_DIR)/ml" check-pydantic-compat
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Format handwritten OpenAPI YAML files
|
||||
|
||||
@@ -12,4 +12,93 @@ Routes live in `routes/` and schemas in `components/`. The `openapi.bundle.yml`
|
||||
|
||||
From the repository root, `make -C api check` checks contracts and `make generate` updates all generated code.
|
||||
|
||||
## Contract conventions
|
||||
|
||||
`api/core/` fixes these conventions as reusable components in `openapi.yml` and the files under `components/`: schemas in `components/schemas/*_schemas.yml`, parameters in `parameters.yml`, response headers in `headers.yml`, responses in `responses.yml`, and examples in `examples.yml`. Operations reference them as they are added. Currently implemented: problem responses for errors of the Go public API and the ML service. Idempotency-Key storage, If-Match checks, and pagination are planned behavior for future business operations; no public operation uses them yet.
|
||||
|
||||
### Errors
|
||||
|
||||
Every error is an RFC 9457 problem with the `application/problem+json` media type and the `Problem` schema. Required fields are `type` (`urn:lincodex:problem:<code>`), `title`, `status`, and `code`; optional ones are `detail`, `instance`, `trace_id` (equal to the `X-Request-ID` response header), and `errors`. Clients branch on `code`. Titles and details are fixed per code and never contain internal error text, stack traces, credentials, contact data, or submitted values.
|
||||
|
||||
| Code | Status | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `validation_failed` | 400 | Parameters or body do not match the contract, or the body violates a domain rule; `errors` lists the fields |
|
||||
| `unauthenticated` | 401 | No valid session |
|
||||
| `forbidden` | 403 | The caller may not perform the operation |
|
||||
| `not_found` | 404 | Unknown route, or an object that does not exist or is not visible |
|
||||
| `method_not_allowed` | 405 | Unsupported method; see `Allow` |
|
||||
| `idempotency_in_progress` | 409 | A request with the same Idempotency-Key is still running |
|
||||
| `state_conflict` | 409 | The operation is not allowed in the current state of the resource |
|
||||
| `version_conflict` | 412 | If-Match does not match the current version |
|
||||
| `payload_too_large` | 413 | The body exceeds the operation limit |
|
||||
| `unsupported_media_type` | 415 | The request Content-Type is not accepted |
|
||||
| `idempotency_key_reused` | 422 | The Idempotency-Key was used with a different request |
|
||||
| `precondition_required` | 428 | The operation requires If-Match |
|
||||
| `rate_limited` | 429 | Too many requests; see `Retry-After` |
|
||||
| `internal` | 500 | Unexpected server error |
|
||||
| `not_implemented` | 501 | The operation is in the contract but not implemented |
|
||||
|
||||
Request validation uses 400 rather than 422. The generated ogen server reports malformed and schema-invalid parameters and bodies through the same decoding errors, and for parameters it does not separate syntax from schema violations; one status keeps client handling uniform. 422 then stays free for Idempotency-Key reuse, as the IETF Idempotency-Key header draft recommends. Domain rules on the body, such as `salary_from <= salary_to`, also answer 400 `validation_failed` with body pointers to the fields involved. Each `errors` item has `in` (`body`, `query`, `path`, `header`, `cookie`), `pointer` (JSON Pointer: `/salary_from` in the body, an empty string for the whole body, `/limit` for a parameter), `code` (`required` or `invalid`; clients tolerate new values), and a fixed `message`. When the decoder does not record the path of a nested body field, the pointer is the whole body. A body cut by an `http.MaxBytesReader` limit answers 413 `payload_too_large`.
|
||||
|
||||
`state_conflict` covers business state conflicts, such as accepting an invitation that was already withdrawn. `idempotency_in_progress` is reserved for concurrent retries; the reusable responses are `StateConflict` and `IdempotencyInProgress`.
|
||||
|
||||
Every operation declares `default: $ref: ../components/responses.yml#/Problem`; ogen then generates a single error type. An operation adds a specific response (for example `PreconditionFailed`) when clients need it in the generated types. In the Go API, unknown paths under `/api`, including paths outside `/api/v1`, answer 404 `not_found`, and a panic in an operation answers 500 `internal`; only the panic type and stack are logged.
|
||||
|
||||
### Retries and Idempotency-Key
|
||||
|
||||
A mutating command declares the `IdempotencyKey` parameter. The client generates a key (a UUID v4 is recommended) and sends it in the `Idempotency-Key` header without quotes: 1-255 characters `A-Z a-z 0-9 . _ : -`. The server scopes the key by caller and operation and fingerprints the request by method, path, and body.
|
||||
|
||||
Stored for 24 hours and replayed with the same status, headers, and body: the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404 `not_found` or 409 `state_conflict`. A replay does not repeat the side effect.
|
||||
|
||||
Not stored, so a retry with the same key is evaluated again: 400 `validation_failed`, 413, and 415 for the request itself; 401 and 403; 409 `idempotency_in_progress`; 412 `version_conflict` and 428 `precondition_required` (nothing changed; read the resource again and retry); 422 `idempotency_key_reused`; 429; and every 5xx.
|
||||
|
||||
The server checks in this order:
|
||||
|
||||
1. Authentication (401), request validation (400, 413, 415), and authorization (403). Nothing is recorded for the key.
|
||||
2. A stored or running request with the same key and a different fingerprint: 422 `idempotency_key_reused`. This check comes before the in-progress check.
|
||||
3. A running request with the same key and fingerprint: 409 `idempotency_in_progress`; retry later.
|
||||
4. A stored outcome with the same key and fingerprint: the outcome is replayed.
|
||||
5. If-Match (428, 412), then the command itself; a storable outcome is recorded.
|
||||
|
||||
Because the replay check comes before If-Match, a retry of a completed change replays its outcome instead of failing on the version that the change itself advanced. A missing or malformed key returns 400 `validation_failed` with the pointer `/Idempotency-Key`. After 24 hours the key may be accepted as new.
|
||||
|
||||
### Versions: ETag and If-Match
|
||||
|
||||
A response with a versioned resource returns a strong `ETag`, for example `"v7"`. An operation that changes such a resource says in its description that it requires `If-Match` with that value. A missing value returns 428 `precondition_required`; a value that does not equal the current ETag returns 412 `version_conflict` and changes nothing. The parameter is optional in the schema so that a missing header reaches the application, which answers 428. Weak tags, lists, and `*` fail validation with 400.
|
||||
|
||||
### Pagination
|
||||
|
||||
Lists use cursor pagination: `limit` from 1 to 100 (20 by default) and an opaque `cursor` of up to 512 characters `A-Z a-z 0-9 _ -`. The response holds the items in a bounded array and `page` (`PageInfo`) with `has_more` and `next_cursor`, which is null on the last page. A malformed cursor returns 400 `validation_failed`.
|
||||
|
||||
### Time and money
|
||||
|
||||
Timestamps use the `Timestamp` schema: `string`, `format: date-time`, UTC with the `Z` suffix (RFC 3339). Servers always emit UTC. ogen generates `Timestamp` as a named Go type over `time.Time`; call `.UTC()` where a value is converted to it. Money is planned as an integer number of whole rubles with explicit fields for the base, such as the pay period and gross or net; the schema is added with the first business field that carries money.
|
||||
|
||||
### ML service errors
|
||||
|
||||
The ML service answers its errors with the same `Problem` schema. FastAPI request validation answers 400 `validation_failed`. An HTTP exception raised inside the service maps by status: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429, and 501 to their codes, 422 to 400 `validation_failed`, any other 4xx to 400 `validation_failed`, and any other 5xx to 500 `internal`. An unhandled exception answers 500 `internal` inside the application, so Starlette does not re-raise it to uvicorn; only its type is logged. The service also routes the uvicorn loggers through its JSON log format, which keeps only the exception type of a record and never its text or traceback.
|
||||
|
||||
### Generator checks
|
||||
|
||||
`testdata/openapi-3.2.0.yml` contains test operations that use the components above: pagination, Idempotency-Key, If-Match, ETag, and problem responses. ogen does not resolve external references, so the fixture keeps copies of the api/core components; `scripts/test_contract_copies.py` (part of `make -C api check`) checks that they, the fixture responses, and the ML `Problem` copy match api/core.
|
||||
|
||||
`make -C api check-toolchain` lints the fixture and runs the three generators on it; it needs the backend Go toolchain, pnpm, and uv, so pass the same `UV` override as for `make generate`.
|
||||
|
||||
| Target | Generator | Exercised conventions |
|
||||
| --- | --- | --- |
|
||||
| `make -C backend check-ogen-compat` | ogen | All of them: Problem, PageInfo, Timestamp, PageLimit, PageCursor, IdempotencyKey, IfMatch, ETag. Its tests check validation errors, the retry scenario, the preconditions, and the 413 body limit against the backend problem mapping |
|
||||
| `make -C frontend check-orval-compat` | Orval | Problem, PageInfo, Timestamp, PageLimit, PageCursor, IdempotencyKey, IfMatch. The output is type-checked with the frontend compiler settings |
|
||||
| `make -C ml check-pydantic-compat` | datamodel-code-generator | Problem, PageInfo, Timestamp, PageLimit, PageCursor. The models pass `mypy --strict` and a validation script |
|
||||
|
||||
Each target writes its output to a temporary directory and removes it.
|
||||
|
||||
Known generator limitations:
|
||||
|
||||
- Orval 8.40 writes no Zod schema for `components/responses` but imports a `<Name>Response` type for each reference. `frontend/codegen/orval.config.ts` therefore inlines response references before generation.
|
||||
- Orval passes header parameters as a typed argument only with `headers: true`. With `exactOptionalPropertyTypes`, an optional header such as `If-Match` fits `RequestInit` only when Zod emits exact optional properties, so the configuration also sets `override.zod.exactOptional`.
|
||||
- Orval generates no type for response headers, and `apiRequest` returns only the body, so a generated client cannot read `ETag` yet. The first operation with a versioned resource must expose it, for example through the response body or the mutator.
|
||||
- datamodel-code-generator 0.83.0 generates models only for schemas and query and path parameters; header parameters and response headers (Idempotency-Key, If-Match, ETag) produce no Python model.
|
||||
- Orval does not generate `additionalOperations` methods.
|
||||
- ogen writes the header name in its canonical Go form (`Etag`); HTTP header names are case-insensitive.
|
||||
|
||||
See the [development guide](../docs/en/DEVELOPMENT.md).
|
||||
@@ -12,4 +12,93 @@
|
||||
|
||||
Из корня: `make -C api check` проверяет контракты, `make generate` обновляет весь сгенерированный код.
|
||||
|
||||
## Соглашения контракта
|
||||
|
||||
`api/core/` закрепляет эти соглашения как переиспользуемые компоненты в `openapi.yml` и файлах `components/`: схемы в `components/schemas/*_schemas.yml`, параметры в `parameters.yml`, заголовки ответов в `headers.yml`, ответы в `responses.yml`, примеры в `examples.yml`. Операции ссылаются на них по мере появления. Сейчас реализованы problem-ответы для ошибок публичного Go API и ML-сервиса. Хранение Idempotency-Key, проверки If-Match и пагинация - запланированное поведение будущих бизнес-операций; ни одна публичная операция их пока не использует.
|
||||
|
||||
### Ошибки
|
||||
|
||||
Любая ошибка - problem по RFC 9457 с media type `application/problem+json` и схемой `Problem`. Обязательные поля: `type` (`urn:lincodex:problem:<code>`), `title`, `status` и `code`; необязательные: `detail`, `instance`, `trace_id` (равен заголовку ответа `X-Request-ID`) и `errors`. Клиенты принимают решения по `code`. Заголовок и описание фиксированы для каждого кода и никогда не содержат текст внутренних ошибок, stack trace, учетные данные, контакты или отправленные значения.
|
||||
|
||||
| Код | Статус | Значение |
|
||||
| --- | --- | --- |
|
||||
| `validation_failed` | 400 | Параметры или тело не соответствуют контракту или тело нарушает доменное правило; `errors` перечисляет поля |
|
||||
| `unauthenticated` | 401 | Нет действующей сессии |
|
||||
| `forbidden` | 403 | Вызывающему запрещена операция |
|
||||
| `not_found` | 404 | Неизвестный маршрут или объект, который не существует или недоступен |
|
||||
| `method_not_allowed` | 405 | Метод не поддерживается; см. `Allow` |
|
||||
| `idempotency_in_progress` | 409 | Запрос с тем же Idempotency-Key еще выполняется |
|
||||
| `state_conflict` | 409 | Операция недопустима в текущем состоянии ресурса |
|
||||
| `version_conflict` | 412 | If-Match не совпадает с текущей версией |
|
||||
| `payload_too_large` | 413 | Тело превышает лимит операции |
|
||||
| `unsupported_media_type` | 415 | Content-Type запроса не принимается |
|
||||
| `idempotency_key_reused` | 422 | Idempotency-Key уже использован с другим запросом |
|
||||
| `precondition_required` | 428 | Операция требует If-Match |
|
||||
| `rate_limited` | 429 | Слишком много запросов; см. `Retry-After` |
|
||||
| `internal` | 500 | Непредвиденная ошибка сервера |
|
||||
| `not_implemented` | 501 | Операция есть в контракте, но не реализована |
|
||||
|
||||
Для валидации запроса выбран 400, а не 422. Сгенерированный ogen-сервер сообщает о синтаксически неверных и не прошедших проверку схемы параметрах и теле через одни и те же ошибки декодирования, а для параметров не отделяет синтаксис от нарушения схемы; единый статус упрощает обработку на клиенте. Поэтому 422 остается для повторного использования Idempotency-Key, как рекомендует черновик IETF о заголовке Idempotency-Key. Доменные правила тела, например `salary_from <= salary_to`, тоже отвечают 400 `validation_failed` с body pointer на участвующие поля. Каждый элемент `errors` содержит `in` (`body`, `query`, `path`, `header`, `cookie`), `pointer` (JSON Pointer: `/salary_from` в теле, пустая строка для всего тела, `/limit` для параметра), `code` (`required` или `invalid`; клиенты допускают новые значения) и фиксированный `message`. Если декодер не сохранил путь вложенного поля тела, pointer указывает на все тело. Тело, обрезанное лимитом `http.MaxBytesReader`, дает 413 `payload_too_large`.
|
||||
|
||||
`state_conflict` обозначает конфликты бизнес-состояния, например принятие уже отозванного приглашения. `idempotency_in_progress` зарезервирован для параллельных повторов; переиспользуемые ответы - `StateConflict` и `IdempotencyInProgress`.
|
||||
|
||||
Каждая операция объявляет `default: $ref: ../components/responses.yml#/Problem`; тогда ogen генерирует единый тип ошибки. Конкретный ответ (например, `PreconditionFailed`) операция добавляет, когда он нужен клиентам в сгенерированных типах. В Go API неизвестные пути под `/api`, включая пути вне `/api/v1`, отвечают 404 `not_found`, а panic в операции - 500 `internal`; в лог попадают только тип panic и stack.
|
||||
|
||||
### Повторы и Idempotency-Key
|
||||
|
||||
Изменяющая команда объявляет параметр `IdempotencyKey`. Клиент создает ключ (рекомендуется UUID v4) и передает его в заголовке `Idempotency-Key` без кавычек: 1-255 символов `A-Z a-z 0-9 . _ : -`. Сервер ограничивает ключ вызывающим и операцией и снимает отпечаток запроса по методу, пути и телу.
|
||||
|
||||
Хранятся 24 часа и воспроизводятся с теми же статусом, заголовками и телом: итоговый 2xx-результат и итоговые детерминированные бизнес-результаты 4xx, например 404 `not_found` или 409 `state_conflict`. Воспроизведение не повторяет побочный эффект.
|
||||
|
||||
Не хранятся, поэтому повтор с тем же ключом обрабатывается заново: 400 `validation_failed`, 413 и 415 для самого запроса; 401 и 403; 409 `idempotency_in_progress`; 412 `version_conflict` и 428 `precondition_required` (ничего не изменилось; прочитайте ресурс снова и повторите); 422 `idempotency_key_reused`; 429; любой 5xx.
|
||||
|
||||
Порядок проверок на сервере:
|
||||
|
||||
1. Аутентификация (401), валидация запроса (400, 413, 415) и авторизация (403). Для ключа ничего не записывается.
|
||||
2. Сохраненный или выполняющийся запрос с тем же ключом и другим отпечатком: 422 `idempotency_key_reused`. Эта проверка идет раньше проверки выполнения.
|
||||
3. Выполняющийся запрос с тем же ключом и отпечатком: 409 `idempotency_in_progress`; повторите позже.
|
||||
4. Сохраненный результат с тем же ключом и отпечатком: результат воспроизводится.
|
||||
5. If-Match (428, 412), затем сама команда; результат, который можно хранить, записывается.
|
||||
|
||||
Поскольку проверка воспроизведения идет раньше If-Match, повтор завершенного изменения воспроизводит его результат, а не падает на версии, которую само изменение и увеличило. Отсутствующий или некорректный ключ дает 400 `validation_failed` с pointer `/Idempotency-Key`. Через 24 часа ключ может быть принят как новый.
|
||||
|
||||
### Версии: ETag и If-Match
|
||||
|
||||
Ответ с версионируемым ресурсом возвращает сильный `ETag`, например `"v7"`. Операция, изменяющая такой ресурс, указывает в описании, что требует `If-Match` с этим значением. Отсутствующее значение дает 428 `precondition_required`; значение, не равное текущему ETag, дает 412 `version_conflict` без изменений. В схеме параметр необязательный, чтобы отсутствие заголовка доходило до приложения, которое отвечает 428. Слабые теги, списки и `*` не проходят валидацию и дают 400.
|
||||
|
||||
### Пагинация
|
||||
|
||||
Списки используют cursor pagination: `limit` от 1 до 100 (по умолчанию 20) и непрозрачный `cursor` длиной до 512 символов `A-Z a-z 0-9 _ -`. Ответ содержит элементы в ограниченном массиве и `page` (`PageInfo`) с `has_more` и `next_cursor`, который равен null на последней странице. Некорректный cursor дает 400 `validation_failed`.
|
||||
|
||||
### Время и деньги
|
||||
|
||||
Метки времени используют схему `Timestamp`: `string`, `format: date-time`, UTC с суффиксом `Z` (RFC 3339). Серверы всегда отдают UTC. ogen генерирует `Timestamp` как именованный Go-тип поверх `time.Time`; при преобразовании к нему вызывайте `.UTC()`. Деньги запланированы как целое число полных рублей с явными полями базы, например периодом оплаты и gross или net; схема появится вместе с первым бизнес-полем с деньгами.
|
||||
|
||||
### Ошибки ML-сервиса
|
||||
|
||||
ML-сервис отвечает на ошибки той же схемой `Problem`. Валидация запроса FastAPI дает 400 `validation_failed`. HTTP-исключение внутри сервиса преобразуется по статусу: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429 и 501 - в свои коды, 422 - в 400 `validation_failed`, любой другой 4xx - в 400 `validation_failed`, любой другой 5xx - в 500 `internal`. Необработанное исключение дает 500 `internal` внутри приложения, поэтому Starlette не пробрасывает его в uvicorn; в лог попадает только тип. Сервис также направляет логгеры uvicorn через свой JSON-формат, который сохраняет только тип исключения записи, но не текст и не traceback.
|
||||
|
||||
### Проверки генераторов
|
||||
|
||||
`testdata/openapi-3.2.0.yml` содержит тестовые операции с перечисленными компонентами: пагинацией, Idempotency-Key, If-Match, ETag и problem-ответами. ogen не разрешает внешние ссылки, поэтому фикстура хранит копии компонентов api/core; `scripts/test_contract_copies.py` (входит в `make -C api check`) проверяет, что они, ответы фикстуры и ML-копия `Problem` совпадают с api/core.
|
||||
|
||||
`make -C api check-toolchain` проверяет фикстуру линтером и запускает на ней три генератора; нужны Go toolchain backend, pnpm и uv, поэтому передавайте тот же `UV` override, что и для `make generate`.
|
||||
|
||||
| Target | Генератор | Проверяемые соглашения |
|
||||
| --- | --- | --- |
|
||||
| `make -C backend check-ogen-compat` | ogen | Все: Problem, PageInfo, Timestamp, PageLimit, PageCursor, IdempotencyKey, IfMatch, ETag. Тесты проверяют ошибки валидации, сценарий повтора, предусловия и лимит тела 413 вместе с backend-маппингом problem |
|
||||
| `make -C frontend check-orval-compat` | Orval | Problem, PageInfo, Timestamp, PageLimit, PageCursor, IdempotencyKey, IfMatch. Результат проходит проверку типов с настройками компилятора frontend |
|
||||
| `make -C ml check-pydantic-compat` | datamodel-code-generator | Problem, PageInfo, Timestamp, PageLimit, PageCursor. Модели проходят `mypy --strict` и скрипт валидации |
|
||||
|
||||
Каждый target пишет результат во временный каталог и удаляет его.
|
||||
|
||||
Известные ограничения генераторов:
|
||||
|
||||
- Orval 8.40 не создает Zod-схемы для `components/responses`, но импортирует тип `<Name>Response` для каждой ссылки. Поэтому `frontend/codegen/orval.config.ts` встраивает ссылки на ответы перед генерацией.
|
||||
- Orval передает header-параметры типизированным аргументом только с `headers: true`. С `exactOptionalPropertyTypes` необязательный заголовок, например `If-Match`, совместим с `RequestInit` только при точных необязательных свойствах Zod, поэтому конфигурация также задает `override.zod.exactOptional`.
|
||||
- Orval не генерирует типы заголовков ответа, а `apiRequest` возвращает только тело, поэтому сгенерированный клиент пока не может прочитать `ETag`. Первая операция с версионируемым ресурсом должна открыть его, например через тело ответа или mutator.
|
||||
- datamodel-code-generator 0.83.0 создает модели только для схем и query- и path-параметров; header-параметры и заголовки ответа (Idempotency-Key, If-Match, ETag) не дают Python-моделей.
|
||||
- Orval не генерирует методы для `additionalOperations`.
|
||||
- ogen записывает имя заголовка в канонической Go-форме (`Etag`); имена HTTP-заголовков не зависят от регистра.
|
||||
|
||||
Подробнее: [разработка](../docs/ru/DEVELOPMENT.md).
|
||||
@@ -0,0 +1,140 @@
|
||||
ValidationFailed:
|
||||
summary: Request parameters do not match the contract
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
trace_id: 0b6f6f0e-7c55-4c8f-a8d1-6f3f3b8f2a10
|
||||
errors:
|
||||
- in: query
|
||||
pointer: /limit
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
- in: header
|
||||
pointer: /Idempotency-Key
|
||||
code: required
|
||||
message: The value is required.
|
||||
Unauthenticated:
|
||||
summary: No valid session
|
||||
value:
|
||||
type: urn:lincodex:problem:unauthenticated
|
||||
title: Authentication required
|
||||
status: 401
|
||||
code: unauthenticated
|
||||
detail: Sign in and repeat the request.
|
||||
trace_id: 4f2d1c3b-6a5e-4d7f-8b9a-0c1d2e3f4a5b
|
||||
Forbidden:
|
||||
summary: The caller may not access the object
|
||||
value:
|
||||
type: urn:lincodex:problem:forbidden
|
||||
title: Access denied
|
||||
status: 403
|
||||
code: forbidden
|
||||
detail: You do not have permission to perform this operation.
|
||||
trace_id: 7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d
|
||||
NotFound:
|
||||
summary: Unknown route or invisible object
|
||||
value:
|
||||
type: urn:lincodex:problem:not_found
|
||||
title: Resource not found
|
||||
status: 404
|
||||
code: not_found
|
||||
detail: The requested resource does not exist.
|
||||
trace_id: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f
|
||||
IdempotencyInProgress:
|
||||
summary: The first request with this key is still running
|
||||
value:
|
||||
type: urn:lincodex:problem:idempotency_in_progress
|
||||
title: Request with this idempotency key is in progress
|
||||
status: 409
|
||||
code: idempotency_in_progress
|
||||
detail: Retry after the original request completes.
|
||||
trace_id: 2d3e4f5a-6b7c-4d8e-9f0a-1b2c3d4e5f6a
|
||||
StateConflict:
|
||||
summary: The resource state does not allow the operation
|
||||
value:
|
||||
type: urn:lincodex:problem:state_conflict
|
||||
title: Resource state conflict
|
||||
status: 409
|
||||
code: state_conflict
|
||||
detail: The resource is in a state that does not allow this operation.
|
||||
trace_id: 1e2f3a4b-5c6d-4e7f-8a9b-0c1d2e3f4a5b
|
||||
DomainValidationFailed:
|
||||
summary: The body violates a domain rule
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
trace_id: 2f3a4b5c-6d7e-4f8a-9b0c-1d2e3f4a5b6c
|
||||
errors:
|
||||
- in: body
|
||||
pointer: /salary_from
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
VersionConflict:
|
||||
summary: If-Match does not match the current version
|
||||
value:
|
||||
type: urn:lincodex:problem:version_conflict
|
||||
title: Resource version conflict
|
||||
status: 412
|
||||
code: version_conflict
|
||||
detail: The resource changed after it was read. Read it again before retrying.
|
||||
trace_id: 3e4f5a6b-7c8d-4e9f-8a0b-2c3d4e5f6a7b
|
||||
PayloadTooLarge:
|
||||
summary: The request body exceeds the limit
|
||||
value:
|
||||
type: urn:lincodex:problem:payload_too_large
|
||||
title: Request body too large
|
||||
status: 413
|
||||
code: payload_too_large
|
||||
detail: Reduce the request body size and retry.
|
||||
trace_id: 8b9c0d1e-2f3a-4b4c-9d5e-6f7a8b9c0d1e
|
||||
IdempotencyKeyReused:
|
||||
summary: The same Idempotency-Key was sent with a different body
|
||||
value:
|
||||
type: urn:lincodex:problem:idempotency_key_reused
|
||||
title: Idempotency key reused with a different request
|
||||
status: 422
|
||||
code: idempotency_key_reused
|
||||
detail: Use a new Idempotency-Key for a different request.
|
||||
trace_id: 4f5a6b7c-8d9e-4f0a-9b1c-3d4e5f6a7b8c
|
||||
PreconditionRequired:
|
||||
summary: The operation requires If-Match
|
||||
value:
|
||||
type: urn:lincodex:problem:precondition_required
|
||||
title: Precondition required
|
||||
status: 428
|
||||
code: precondition_required
|
||||
detail: Send If-Match with the ETag of the version you read.
|
||||
trace_id: 5a6b7c8d-9e0f-4a1b-8c2d-4e5f6a7b8c9d
|
||||
RateLimited:
|
||||
summary: Too many requests
|
||||
value:
|
||||
type: urn:lincodex:problem:rate_limited
|
||||
title: Too many requests
|
||||
status: 429
|
||||
code: rate_limited
|
||||
detail: Wait for the Retry-After interval and retry.
|
||||
trace_id: 6b7c8d9e-0f1a-4b2c-9d3e-5f6a7b8c9d0e
|
||||
Internal:
|
||||
summary: Unexpected server error
|
||||
value:
|
||||
type: urn:lincodex:problem:internal
|
||||
title: Internal server error
|
||||
status: 500
|
||||
code: internal
|
||||
detail: The server could not complete the request.
|
||||
trace_id: 9c0d1e2f-3a4b-4c5d-8e6f-7a8b9c0d1e2f
|
||||
NotImplemented:
|
||||
summary: Operation declared in the contract without an implementation
|
||||
value:
|
||||
type: urn:lincodex:problem:not_implemented
|
||||
title: Operation not implemented
|
||||
status: 501
|
||||
code: not_implemented
|
||||
detail: This operation is not available yet.
|
||||
trace_id: 0d1e2f3a-4b5c-4d6e-9f7a-8b9c0d1e2f3a
|
||||
@@ -0,0 +1,19 @@
|
||||
ETag:
|
||||
description: >-
|
||||
Strong entity tag of the returned resource version. Send it back in
|
||||
If-Match to change this version.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: '^"[A-Za-z0-9._~-]{1,128}"$'
|
||||
example: '"v7"'
|
||||
RetryAfter:
|
||||
description: Number of seconds to wait before retrying the request.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 86400
|
||||
example: 30
|
||||
@@ -0,0 +1,58 @@
|
||||
IdempotencyKey:
|
||||
name: Idempotency-Key
|
||||
in: header
|
||||
required: true
|
||||
description: |-
|
||||
Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value is sent without quotes. The server scopes the key by caller and operation and fingerprints the request by method, path, and body.
|
||||
|
||||
Stored for 24 hours after the first request and replayed with the same status, headers, and body: the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404 not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
|
||||
Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428 precondition_required (nothing changed; read the resource again and retry), 422 idempotency_key_reused, 429, and every 5xx.
|
||||
|
||||
Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused before any other key check; a running request with the same fingerprint returns 409 idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that does the server check If-Match, so a retry of a completed change replays its outcome instead of failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
pattern: "^[A-Za-z0-9._:-]+$"
|
||||
example: 5f0c6a8e-3b0e-4c47-9f4c-2a8f9e5d7c11
|
||||
IfMatch:
|
||||
name: If-Match
|
||||
in: header
|
||||
required: false
|
||||
description: |-
|
||||
Strong entity tag of the resource version the client last read, copied from the ETag response header. An operation that changes a versioned resource says in its own description that it requires If-Match.
|
||||
|
||||
On such an operation, a missing If-Match returns 428 precondition_required. An If-Match that does not equal the current ETag returns 412 version_conflict and changes nothing; read the resource again before retrying. Only one strong entity tag is accepted; weak tags, lists, and `*` fail validation with 400. The parameter is optional in the schema so that a missing header reaches the application, which answers 428.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: '^"[A-Za-z0-9._~-]{1,128}"$'
|
||||
example: '"v7"'
|
||||
PageLimit:
|
||||
name: limit
|
||||
in: query
|
||||
required: false
|
||||
description: >-
|
||||
Maximum number of items in the page. The server may return fewer items
|
||||
even when more remain; use `page.has_more` to detect the end.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
default: 20
|
||||
PageCursor:
|
||||
name: cursor
|
||||
in: query
|
||||
required: false
|
||||
description: >-
|
||||
Opaque `page.next_cursor` value from the previous page of the same listing.
|
||||
Omit it to read the first page. A malformed or foreign cursor returns 400
|
||||
with code validation_failed.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: "^[A-Za-z0-9_-]+$"
|
||||
@@ -0,0 +1,159 @@
|
||||
ValidationFailed:
|
||||
description: >-
|
||||
Parameters, headers, or the body do not match the contract, or the body
|
||||
violates a domain rule such as salary_from <= salary_to. The body has code
|
||||
validation_failed and lists the failing fields in `errors` with body or
|
||||
parameter pointers.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
validation_failed:
|
||||
$ref: ./examples.yml#/ValidationFailed
|
||||
domain_rule:
|
||||
$ref: ./examples.yml#/DomainValidationFailed
|
||||
Unauthenticated:
|
||||
description: No valid session or credentials; code unauthenticated.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
unauthenticated:
|
||||
$ref: ./examples.yml#/Unauthenticated
|
||||
Forbidden:
|
||||
description: >-
|
||||
The caller is authenticated but may not perform the operation; code
|
||||
forbidden.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
forbidden:
|
||||
$ref: ./examples.yml#/Forbidden
|
||||
NotFound:
|
||||
description: >-
|
||||
The object does not exist or is not visible to the caller; code
|
||||
not_found. Missing and inaccessible objects are not distinguished.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
not_found:
|
||||
$ref: ./examples.yml#/NotFound
|
||||
IdempotencyInProgress:
|
||||
description: >-
|
||||
A request with the same Idempotency-Key and the same fingerprint is still
|
||||
being processed; code idempotency_in_progress. Retry after the original
|
||||
request completes.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
idempotency_in_progress:
|
||||
$ref: ./examples.yml#/IdempotencyInProgress
|
||||
StateConflict:
|
||||
description: >-
|
||||
The operation conflicts with the current state of the resource, for
|
||||
example a transition that is not allowed from its current status; code
|
||||
state_conflict.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
state_conflict:
|
||||
$ref: ./examples.yml#/StateConflict
|
||||
PreconditionFailed:
|
||||
description: >-
|
||||
If-Match does not match the current resource version; code
|
||||
version_conflict. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
version_conflict:
|
||||
$ref: ./examples.yml#/VersionConflict
|
||||
PayloadTooLarge:
|
||||
description: The request body exceeds the operation limit; code payload_too_large.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
payload_too_large:
|
||||
$ref: ./examples.yml#/PayloadTooLarge
|
||||
UnprocessableContent:
|
||||
description: >-
|
||||
The Idempotency-Key was already used with a different request within 24
|
||||
hours; code idempotency_key_reused. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
idempotency_key_reused:
|
||||
$ref: ./examples.yml#/IdempotencyKeyReused
|
||||
PreconditionRequired:
|
||||
description: The operation requires If-Match; code precondition_required.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
precondition_required:
|
||||
$ref: ./examples.yml#/PreconditionRequired
|
||||
TooManyRequests:
|
||||
description: Too many requests; code rate_limited.
|
||||
headers:
|
||||
Retry-After:
|
||||
$ref: ./headers.yml#/RetryAfter
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
rate_limited:
|
||||
$ref: ./examples.yml#/RateLimited
|
||||
Internal:
|
||||
description: Unexpected server error; code internal.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
internal:
|
||||
$ref: ./examples.yml#/Internal
|
||||
NotImplemented:
|
||||
description: >-
|
||||
The operation is declared in the contract but not implemented yet; code
|
||||
not_implemented.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
not_implemented:
|
||||
$ref: ./examples.yml#/NotImplemented
|
||||
Problem:
|
||||
description: >-
|
||||
Any error response. The body is a Problem whose `status` equals the HTTP
|
||||
status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
validation_failed:
|
||||
$ref: ./examples.yml#/ValidationFailed
|
||||
not_found:
|
||||
$ref: ./examples.yml#/NotFound
|
||||
internal:
|
||||
$ref: ./examples.yml#/Internal
|
||||
not_implemented:
|
||||
$ref: ./examples.yml#/NotImplemented
|
||||
@@ -1,3 +1,28 @@
|
||||
Timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
description: UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.
|
||||
examples:
|
||||
- '2026-10-05T09:30:00Z'
|
||||
PageInfo:
|
||||
type: object
|
||||
description: Cursor pagination state of a list response. Lists are ordered by a stable server-defined key. To read the next page, repeat the request with the same filters and `cursor` set to `next_cursor`.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- has_more
|
||||
- next_cursor
|
||||
properties:
|
||||
has_more:
|
||||
type: boolean
|
||||
description: Whether another page follows this one.
|
||||
next_cursor:
|
||||
type:
|
||||
- string
|
||||
- 'null'
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: ^[A-Za-z0-9_-]+$
|
||||
description: Opaque cursor of the next page, or null on the last page. Clients must not parse, build, or store it beyond the current listing.
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
@@ -8,3 +33,139 @@ HealthResponse:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier, equal to the X-Request-ID response header. Quote it when reporting the problem; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/ProblemFieldError'
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: 'Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
|
||||
- internal (500): unexpected server error.
|
||||
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.'
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
@@ -0,0 +1,34 @@
|
||||
schemas:
|
||||
Timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
description: >-
|
||||
UTC instant in RFC 3339 format with the Z suffix, for example
|
||||
2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in
|
||||
this contract uses this schema.
|
||||
examples:
|
||||
- "2026-10-05T09:30:00Z"
|
||||
PageInfo:
|
||||
type: object
|
||||
description: >-
|
||||
Cursor pagination state of a list response. Lists are ordered by a
|
||||
stable server-defined key. To read the next page, repeat the request
|
||||
with the same filters and `cursor` set to `next_cursor`.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- has_more
|
||||
- next_cursor
|
||||
properties:
|
||||
has_more:
|
||||
type: boolean
|
||||
description: Whether another page follows this one.
|
||||
next_cursor:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: "^[A-Za-z0-9_-]+$"
|
||||
description: >-
|
||||
Opaque cursor of the next page, or null on the last page. Clients
|
||||
must not parse, build, or store it beyond the current listing.
|
||||
@@ -0,0 +1,146 @@
|
||||
schemas:
|
||||
Problem:
|
||||
type: object
|
||||
description: >-
|
||||
Problem details (RFC 9457) returned with the application/problem+json
|
||||
media type for every error response. `code` is the stable,
|
||||
machine-readable reason; clients branch on it rather than on `title`,
|
||||
`detail`, or the HTTP status alone. The body never contains internal
|
||||
error text, stack traces, SQL, file paths, credentials, contact data, or
|
||||
echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: >-
|
||||
URI that identifies the problem type. It has the form
|
||||
`urn:lincodex:problem:<code>` and is an identifier, not a link to
|
||||
dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: >-
|
||||
Short, fixed English summary of the problem type. It does not change
|
||||
between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: "#/schemas/ProblemCode"
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: >-
|
||||
Safe English explanation of this occurrence. It never contains
|
||||
internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: "^[A-Za-z0-9._-]+$"
|
||||
description: >-
|
||||
Request identifier, equal to the X-Request-ID response header. Quote
|
||||
it when reporting the problem; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: >-
|
||||
Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: "#/schemas/ProblemFieldError"
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: "#/schemas/ProblemFieldLocation"
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: "^(/([^~/]|~[01])*)*$"
|
||||
description: >-
|
||||
JSON Pointer (RFC 6901). For `body` it points into the request body
|
||||
document, for example `/salary_from`; an empty string means the whole
|
||||
body. For a parameter it is `/` followed by the parameter name, for
|
||||
example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: "^[a-z][a-z0-9_]*$"
|
||||
description: >-
|
||||
Stable field reason. Current values are `required` (missing value)
|
||||
and `invalid` (malformed value or a value outside the schema).
|
||||
Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
@@ -19,8 +19,162 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/HealthResponse'
|
||||
examples:
|
||||
ok:
|
||||
summary: The process is responding
|
||||
value:
|
||||
status: ok
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
components:
|
||||
schemas:
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/components/schemas/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier, equal to the X-Request-ID response header. Quote it when reporting the problem; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/components/schemas/ProblemFieldError'
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/components/schemas/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
Timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
description: UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.
|
||||
examples:
|
||||
- '2026-10-05T09:30:00Z'
|
||||
PageInfo:
|
||||
type: object
|
||||
description: Cursor pagination state of a list response. Lists are ordered by a stable server-defined key. To read the next page, repeat the request with the same filters and `cursor` set to `next_cursor`.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- has_more
|
||||
- next_cursor
|
||||
properties:
|
||||
has_more:
|
||||
type: boolean
|
||||
description: Whether another page follows this one.
|
||||
next_cursor:
|
||||
type:
|
||||
- string
|
||||
- 'null'
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: ^[A-Za-z0-9_-]+$
|
||||
description: Opaque cursor of the next page, or null on the last page. Clients must not parse, build, or store it beyond the current listing.
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
@@ -31,3 +185,354 @@ components:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
parameters:
|
||||
IdempotencyKey:
|
||||
name: Idempotency-Key
|
||||
in: header
|
||||
required: true
|
||||
description: |-
|
||||
Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value is sent without quotes. The server scopes the key by caller and operation and fingerprints the request by method, path, and body.
|
||||
|
||||
Stored for 24 hours after the first request and replayed with the same status, headers, and body: the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404 not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
|
||||
Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428 precondition_required (nothing changed; read the resource again and retry), 422 idempotency_key_reused, 429, and every 5xx.
|
||||
|
||||
Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused before any other key check; a running request with the same fingerprint returns 409 idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that does the server check If-Match, so a retry of a completed change replays its outcome instead of failing on the version it has just changed. After 24 hours the key may be accepted as new.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
pattern: ^[A-Za-z0-9._:-]+$
|
||||
example: 5f0c6a8e-3b0e-4c47-9f4c-2a8f9e5d7c11
|
||||
IfMatch:
|
||||
name: If-Match
|
||||
in: header
|
||||
required: false
|
||||
description: |-
|
||||
Strong entity tag of the resource version the client last read, copied from the ETag response header. An operation that changes a versioned resource says in its own description that it requires If-Match.
|
||||
|
||||
On such an operation, a missing If-Match returns 428 precondition_required. An If-Match that does not equal the current ETag returns 412 version_conflict and changes nothing; read the resource again before retrying. Only one strong entity tag is accepted; weak tags, lists, and `*` fail validation with 400. The parameter is optional in the schema so that a missing header reaches the application, which answers 428.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: ^"[A-Za-z0-9._~-]{1,128}"$
|
||||
example: '"v7"'
|
||||
PageLimit:
|
||||
name: limit
|
||||
in: query
|
||||
required: false
|
||||
description: Maximum number of items in the page. The server may return fewer items even when more remain; use `page.has_more` to detect the end.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
default: 20
|
||||
PageCursor:
|
||||
name: cursor
|
||||
in: query
|
||||
required: false
|
||||
description: Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the first page. A malformed or foreign cursor returns 400 with code validation_failed.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: ^[A-Za-z0-9_-]+$
|
||||
headers:
|
||||
ETag:
|
||||
description: Strong entity tag of the returned resource version. Send it back in If-Match to change this version.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: ^"[A-Za-z0-9._~-]{1,128}"$
|
||||
example: '"v7"'
|
||||
RetryAfter:
|
||||
description: Number of seconds to wait before retrying the request.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 86400
|
||||
example: 30
|
||||
responses:
|
||||
ValidationFailed:
|
||||
description: Parameters, headers, or the body do not match the contract, or the body violates a domain rule such as salary_from <= salary_to. The body has code validation_failed and lists the failing fields in `errors` with body or parameter pointers.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
validation_failed:
|
||||
$ref: '#/components/examples/ValidationFailed'
|
||||
domain_rule:
|
||||
$ref: '#/components/examples/DomainValidationFailed'
|
||||
Unauthenticated:
|
||||
description: No valid session or credentials; code unauthenticated.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
unauthenticated:
|
||||
$ref: '#/components/examples/Unauthenticated'
|
||||
Forbidden:
|
||||
description: The caller is authenticated but may not perform the operation; code forbidden.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
forbidden:
|
||||
$ref: '#/components/examples/Forbidden'
|
||||
NotFound:
|
||||
description: The object does not exist or is not visible to the caller; code not_found. Missing and inaccessible objects are not distinguished.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
not_found:
|
||||
$ref: '#/components/examples/NotFound'
|
||||
IdempotencyInProgress:
|
||||
description: A request with the same Idempotency-Key and the same fingerprint is still being processed; code idempotency_in_progress. Retry after the original request completes.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
idempotency_in_progress:
|
||||
$ref: '#/components/examples/IdempotencyInProgress'
|
||||
StateConflict:
|
||||
description: The operation conflicts with the current state of the resource, for example a transition that is not allowed from its current status; code state_conflict.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
state_conflict:
|
||||
$ref: '#/components/examples/StateConflict'
|
||||
PreconditionFailed:
|
||||
description: If-Match does not match the current resource version; code version_conflict. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
version_conflict:
|
||||
$ref: '#/components/examples/VersionConflict'
|
||||
PayloadTooLarge:
|
||||
description: The request body exceeds the operation limit; code payload_too_large.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
payload_too_large:
|
||||
$ref: '#/components/examples/PayloadTooLarge'
|
||||
UnprocessableContent:
|
||||
description: The Idempotency-Key was already used with a different request within 24 hours; code idempotency_key_reused. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
idempotency_key_reused:
|
||||
$ref: '#/components/examples/IdempotencyKeyReused'
|
||||
PreconditionRequired:
|
||||
description: The operation requires If-Match; code precondition_required.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
precondition_required:
|
||||
$ref: '#/components/examples/PreconditionRequired'
|
||||
TooManyRequests:
|
||||
description: Too many requests; code rate_limited.
|
||||
headers:
|
||||
Retry-After:
|
||||
$ref: '#/components/headers/RetryAfter'
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
rate_limited:
|
||||
$ref: '#/components/examples/RateLimited'
|
||||
Internal:
|
||||
description: Unexpected server error; code internal.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
internal:
|
||||
$ref: '#/components/examples/Internal'
|
||||
NotImplemented:
|
||||
description: The operation is declared in the contract but not implemented yet; code not_implemented.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
not_implemented:
|
||||
$ref: '#/components/examples/NotImplemented'
|
||||
Problem:
|
||||
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
validation_failed:
|
||||
$ref: '#/components/examples/ValidationFailed'
|
||||
not_found:
|
||||
$ref: '#/components/examples/NotFound'
|
||||
internal:
|
||||
$ref: '#/components/examples/Internal'
|
||||
not_implemented:
|
||||
$ref: '#/components/examples/NotImplemented'
|
||||
examples:
|
||||
ValidationFailed:
|
||||
summary: Request parameters do not match the contract
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
trace_id: 0b6f6f0e-7c55-4c8f-a8d1-6f3f3b8f2a10
|
||||
errors:
|
||||
- in: query
|
||||
pointer: /limit
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
- in: header
|
||||
pointer: /Idempotency-Key
|
||||
code: required
|
||||
message: The value is required.
|
||||
NotFound:
|
||||
summary: Unknown route or invisible object
|
||||
value:
|
||||
type: urn:lincodex:problem:not_found
|
||||
title: Resource not found
|
||||
status: 404
|
||||
code: not_found
|
||||
detail: The requested resource does not exist.
|
||||
trace_id: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f
|
||||
Internal:
|
||||
summary: Unexpected server error
|
||||
value:
|
||||
type: urn:lincodex:problem:internal
|
||||
title: Internal server error
|
||||
status: 500
|
||||
code: internal
|
||||
detail: The server could not complete the request.
|
||||
trace_id: 9c0d1e2f-3a4b-4c5d-8e6f-7a8b9c0d1e2f
|
||||
NotImplemented:
|
||||
summary: Operation declared in the contract without an implementation
|
||||
value:
|
||||
type: urn:lincodex:problem:not_implemented
|
||||
title: Operation not implemented
|
||||
status: 501
|
||||
code: not_implemented
|
||||
detail: This operation is not available yet.
|
||||
trace_id: 0d1e2f3a-4b5c-4d6e-9f7a-8b9c0d1e2f3a
|
||||
DomainValidationFailed:
|
||||
summary: The body violates a domain rule
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
trace_id: 2f3a4b5c-6d7e-4f8a-9b0c-1d2e3f4a5b6c
|
||||
errors:
|
||||
- in: body
|
||||
pointer: /salary_from
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
Unauthenticated:
|
||||
summary: No valid session
|
||||
value:
|
||||
type: urn:lincodex:problem:unauthenticated
|
||||
title: Authentication required
|
||||
status: 401
|
||||
code: unauthenticated
|
||||
detail: Sign in and repeat the request.
|
||||
trace_id: 4f2d1c3b-6a5e-4d7f-8b9a-0c1d2e3f4a5b
|
||||
Forbidden:
|
||||
summary: The caller may not access the object
|
||||
value:
|
||||
type: urn:lincodex:problem:forbidden
|
||||
title: Access denied
|
||||
status: 403
|
||||
code: forbidden
|
||||
detail: You do not have permission to perform this operation.
|
||||
trace_id: 7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d
|
||||
IdempotencyInProgress:
|
||||
summary: The first request with this key is still running
|
||||
value:
|
||||
type: urn:lincodex:problem:idempotency_in_progress
|
||||
title: Request with this idempotency key is in progress
|
||||
status: 409
|
||||
code: idempotency_in_progress
|
||||
detail: Retry after the original request completes.
|
||||
trace_id: 2d3e4f5a-6b7c-4d8e-9f0a-1b2c3d4e5f6a
|
||||
StateConflict:
|
||||
summary: The resource state does not allow the operation
|
||||
value:
|
||||
type: urn:lincodex:problem:state_conflict
|
||||
title: Resource state conflict
|
||||
status: 409
|
||||
code: state_conflict
|
||||
detail: The resource is in a state that does not allow this operation.
|
||||
trace_id: 1e2f3a4b-5c6d-4e7f-8a9b-0c1d2e3f4a5b
|
||||
VersionConflict:
|
||||
summary: If-Match does not match the current version
|
||||
value:
|
||||
type: urn:lincodex:problem:version_conflict
|
||||
title: Resource version conflict
|
||||
status: 412
|
||||
code: version_conflict
|
||||
detail: The resource changed after it was read. Read it again before retrying.
|
||||
trace_id: 3e4f5a6b-7c8d-4e9f-8a0b-2c3d4e5f6a7b
|
||||
PayloadTooLarge:
|
||||
summary: The request body exceeds the limit
|
||||
value:
|
||||
type: urn:lincodex:problem:payload_too_large
|
||||
title: Request body too large
|
||||
status: 413
|
||||
code: payload_too_large
|
||||
detail: Reduce the request body size and retry.
|
||||
trace_id: 8b9c0d1e-2f3a-4b4c-9d5e-6f7a8b9c0d1e
|
||||
IdempotencyKeyReused:
|
||||
summary: The same Idempotency-Key was sent with a different body
|
||||
value:
|
||||
type: urn:lincodex:problem:idempotency_key_reused
|
||||
title: Idempotency key reused with a different request
|
||||
status: 422
|
||||
code: idempotency_key_reused
|
||||
detail: Use a new Idempotency-Key for a different request.
|
||||
trace_id: 4f5a6b7c-8d9e-4f0a-9b1c-3d4e5f6a7b8c
|
||||
PreconditionRequired:
|
||||
summary: The operation requires If-Match
|
||||
value:
|
||||
type: urn:lincodex:problem:precondition_required
|
||||
title: Precondition required
|
||||
status: 428
|
||||
code: precondition_required
|
||||
detail: Send If-Match with the ETag of the version you read.
|
||||
trace_id: 5a6b7c8d-9e0f-4a1b-8c2d-4e5f6a7b8c9d
|
||||
RateLimited:
|
||||
summary: Too many requests
|
||||
value:
|
||||
type: urn:lincodex:problem:rate_limited
|
||||
title: Too many requests
|
||||
status: 429
|
||||
code: rate_limited
|
||||
detail: Wait for the Retry-After interval and retry.
|
||||
trace_id: 6b7c8d9e-0f1a-4b2c-9d3e-5f6a7b8c9d0e
|
||||
@@ -7,3 +7,60 @@ servers:
|
||||
paths:
|
||||
/api/v1/healthz:
|
||||
$ref: ./routes/healthz.yml
|
||||
components:
|
||||
schemas:
|
||||
Problem:
|
||||
$ref: ./components/schemas.yml#/Problem
|
||||
ProblemCode:
|
||||
$ref: ./components/schemas.yml#/ProblemCode
|
||||
ProblemFieldError:
|
||||
$ref: ./components/schemas.yml#/ProblemFieldError
|
||||
ProblemFieldLocation:
|
||||
$ref: ./components/schemas.yml#/ProblemFieldLocation
|
||||
Timestamp:
|
||||
$ref: ./components/schemas.yml#/Timestamp
|
||||
PageInfo:
|
||||
$ref: ./components/schemas.yml#/PageInfo
|
||||
parameters:
|
||||
IdempotencyKey:
|
||||
$ref: ./components/parameters.yml#/IdempotencyKey
|
||||
IfMatch:
|
||||
$ref: ./components/parameters.yml#/IfMatch
|
||||
PageLimit:
|
||||
$ref: ./components/parameters.yml#/PageLimit
|
||||
PageCursor:
|
||||
$ref: ./components/parameters.yml#/PageCursor
|
||||
headers:
|
||||
ETag:
|
||||
$ref: ./components/headers.yml#/ETag
|
||||
RetryAfter:
|
||||
$ref: ./components/headers.yml#/RetryAfter
|
||||
responses:
|
||||
ValidationFailed:
|
||||
$ref: ./components/responses.yml#/ValidationFailed
|
||||
Unauthenticated:
|
||||
$ref: ./components/responses.yml#/Unauthenticated
|
||||
Forbidden:
|
||||
$ref: ./components/responses.yml#/Forbidden
|
||||
NotFound:
|
||||
$ref: ./components/responses.yml#/NotFound
|
||||
IdempotencyInProgress:
|
||||
$ref: ./components/responses.yml#/IdempotencyInProgress
|
||||
StateConflict:
|
||||
$ref: ./components/responses.yml#/StateConflict
|
||||
PreconditionFailed:
|
||||
$ref: ./components/responses.yml#/PreconditionFailed
|
||||
PayloadTooLarge:
|
||||
$ref: ./components/responses.yml#/PayloadTooLarge
|
||||
UnprocessableContent:
|
||||
$ref: ./components/responses.yml#/UnprocessableContent
|
||||
PreconditionRequired:
|
||||
$ref: ./components/responses.yml#/PreconditionRequired
|
||||
TooManyRequests:
|
||||
$ref: ./components/responses.yml#/TooManyRequests
|
||||
Internal:
|
||||
$ref: ./components/responses.yml#/Internal
|
||||
NotImplemented:
|
||||
$ref: ./components/responses.yml#/NotImplemented
|
||||
Problem:
|
||||
$ref: ./components/responses.yml#/Problem
|
||||
@@ -11,3 +11,10 @@ get:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/HealthResponse
|
||||
examples:
|
||||
ok:
|
||||
summary: The process is responding
|
||||
value:
|
||||
status: ok
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,30 @@
|
||||
Problem:
|
||||
description: >-
|
||||
Any error response. The body is a Problem whose `status` equals the HTTP
|
||||
status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
validation_failed:
|
||||
summary: Request parameters do not match the contract
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
errors:
|
||||
- in: query
|
||||
pointer: /limit
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
internal:
|
||||
summary: Unexpected server error
|
||||
value:
|
||||
type: urn:lincodex:problem:internal
|
||||
title: Internal server error
|
||||
status: 500
|
||||
code: internal
|
||||
detail: The server could not complete the request.
|
||||
@@ -8,6 +8,142 @@ MLHealthResponse:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the ML service copy of the public api/core Problem schema; keep both copies identical except for descriptions. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier of the call when the caller propagated one; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/ProblemFieldError'
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: 'Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
|
||||
- internal (500): unexpected server error.
|
||||
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.'
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
MLReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
schemas:
|
||||
Problem:
|
||||
type: object
|
||||
description: >-
|
||||
Problem details (RFC 9457) returned with the application/problem+json
|
||||
media type for every error response. This is the ML service copy of the
|
||||
public api/core Problem schema; keep both copies identical except for
|
||||
descriptions. `code` is the stable,
|
||||
machine-readable reason; clients branch on it rather than on `title`,
|
||||
`detail`, or the HTTP status alone. The body never contains internal
|
||||
error text, stack traces, SQL, file paths, credentials, contact data, or
|
||||
echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: >-
|
||||
URI that identifies the problem type. It has the form
|
||||
`urn:lincodex:problem:<code>` and is an identifier, not a link to
|
||||
dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: >-
|
||||
Short, fixed English summary of the problem type. It does not change
|
||||
between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: "#/schemas/ProblemCode"
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: >-
|
||||
Safe English explanation of this occurrence. It never contains
|
||||
internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: "^[A-Za-z0-9._-]+$"
|
||||
description: >-
|
||||
Request identifier of the call when the caller propagated one; it is
|
||||
not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: >-
|
||||
Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: "#/schemas/ProblemFieldError"
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: "#/schemas/ProblemFieldLocation"
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: "^(/([^~/]|~[01])*)*$"
|
||||
description: >-
|
||||
JSON Pointer (RFC 6901). For `body` it points into the request body
|
||||
document, for example `/salary_from`; an empty string means the whole
|
||||
body. For a parameter it is `/` followed by the parameter name, for
|
||||
example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: "^[a-z][a-z0-9_]*$"
|
||||
description: >-
|
||||
Stable field reason. Current values are `required` (missing value)
|
||||
and `invalid` (malformed value or a value outside the schema).
|
||||
Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
@@ -19,6 +19,8 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MLHealthResponse'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/readyz:
|
||||
get:
|
||||
operationId: GetMLReadyz
|
||||
@@ -39,8 +41,161 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MLReadinessResponse'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
components:
|
||||
responses:
|
||||
Problem:
|
||||
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
validation_failed:
|
||||
summary: Request parameters do not match the contract
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
errors:
|
||||
- in: query
|
||||
pointer: /limit
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
internal:
|
||||
summary: Unexpected server error
|
||||
value:
|
||||
type: urn:lincodex:problem:internal
|
||||
title: Internal server error
|
||||
status: 500
|
||||
code: internal
|
||||
detail: The server could not complete the request.
|
||||
schemas:
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/components/schemas/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the ML service copy of the public api/core Problem schema; keep both copies identical except for descriptions. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/components/schemas/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier of the call when the caller propagated one; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/components/schemas/ProblemFieldError'
|
||||
MLHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
||||
@@ -9,3 +9,7 @@ paths:
|
||||
$ref: ./routes/healthz.yml
|
||||
/readyz:
|
||||
$ref: ./routes/readyz.yml
|
||||
components:
|
||||
responses:
|
||||
Problem:
|
||||
$ref: ./components/responses.yml#/Problem
|
||||
@@ -11,3 +11,5 @@ get:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/MLHealthResponse
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -17,3 +17,5 @@ get:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/MLReadinessResponse
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
Vendored
+394
@@ -2,6 +2,12 @@ openapi: 3.2.0
|
||||
info:
|
||||
title: OpenAPI 3.2 compatibility fixture
|
||||
version: 0.1.0
|
||||
description: >-
|
||||
Exercises the OpenAPI 3.2 subset and the api/core conventions (problem
|
||||
details, cursor pagination, Idempotency-Key, If-Match, and ETag) through
|
||||
the pinned generators. The operations are test fixtures, not product
|
||||
endpoints. Component definitions shared with api/core are copies that must
|
||||
stay identical to the api/core bundle.
|
||||
servers:
|
||||
- url: /
|
||||
paths:
|
||||
@@ -25,6 +31,8 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/NullablePayload"
|
||||
default:
|
||||
$ref: "#/components/responses/Problem"
|
||||
additionalOperations:
|
||||
PURGE:
|
||||
operationId: PurgeProbe
|
||||
@@ -33,6 +41,90 @@ paths:
|
||||
responses:
|
||||
"204":
|
||||
description: The compatibility fixture operation completed.
|
||||
default:
|
||||
$ref: "#/components/responses/Problem"
|
||||
/probe/items:
|
||||
get:
|
||||
operationId: ListProbeItems
|
||||
summary: Exercise bounded cursor pagination.
|
||||
security: []
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/PageLimit"
|
||||
- $ref: "#/components/parameters/PageCursor"
|
||||
responses:
|
||||
"200":
|
||||
description: One page of fixture items.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProbeItemPage"
|
||||
default:
|
||||
$ref: "#/components/responses/Problem"
|
||||
post:
|
||||
operationId: CreateProbeItem
|
||||
summary: Exercise an idempotent mutating command.
|
||||
security: []
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/IdempotencyKey"
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProbeItemInput"
|
||||
responses:
|
||||
"201":
|
||||
description: The fixture item was created or the stored response was replayed.
|
||||
headers:
|
||||
ETag:
|
||||
$ref: "#/components/headers/ETag"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProbeItem"
|
||||
"409":
|
||||
$ref: "#/components/responses/IdempotencyInProgress"
|
||||
"422":
|
||||
$ref: "#/components/responses/UnprocessableContent"
|
||||
default:
|
||||
$ref: "#/components/responses/Problem"
|
||||
/probe/items/{item_id}:
|
||||
patch:
|
||||
operationId: UpdateProbeItem
|
||||
summary: Exercise optimistic concurrency with If-Match and ETag.
|
||||
description: This operation requires If-Match; without it the fixture handler answers 428 precondition_required.
|
||||
security: []
|
||||
parameters:
|
||||
- name: item_id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
- $ref: "#/components/parameters/IdempotencyKey"
|
||||
- $ref: "#/components/parameters/IfMatch"
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProbeItemInput"
|
||||
responses:
|
||||
"200":
|
||||
description: The fixture item was updated.
|
||||
headers:
|
||||
ETag:
|
||||
$ref: "#/components/headers/ETag"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProbeItem"
|
||||
"412":
|
||||
$ref: "#/components/responses/PreconditionFailed"
|
||||
"428":
|
||||
$ref: "#/components/responses/PreconditionRequired"
|
||||
default:
|
||||
$ref: "#/components/responses/Problem"
|
||||
components:
|
||||
schemas:
|
||||
NullablePayload:
|
||||
@@ -45,3 +137,305 @@ components:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
ProbeItemInput:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 100
|
||||
ProbeItem:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- updated_at
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 100
|
||||
updated_at:
|
||||
$ref: "#/components/schemas/Timestamp"
|
||||
ProbeItemPage:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- items
|
||||
- page
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
maxItems: 100
|
||||
items:
|
||||
$ref: "#/components/schemas/ProbeItem"
|
||||
page:
|
||||
$ref: "#/components/schemas/PageInfo"
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: "#/components/schemas/ProblemCode"
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier, equal to the X-Request-ID response header. Quote it when reporting the problem; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: "#/components/schemas/ProblemFieldError"
|
||||
ProblemCode:
|
||||
type: string
|
||||
description:
|
||||
"Stable public error code. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract, or a body violates a domain rule such as salary_from <= salary_to; `errors` points at the fields.
|
||||
|
||||
- unauthenticated (401): no valid session or credentials.
|
||||
|
||||
- forbidden (403): the caller is authenticated but not allowed.
|
||||
|
||||
- not_found (404): the route or object does not exist or is not visible.
|
||||
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
|
||||
- idempotency_in_progress (409): a request with the same Idempotency-Key is still being processed.
|
||||
|
||||
- state_conflict (409): the operation conflicts with the current state of the resource, for example an invitation that was already accepted.
|
||||
|
||||
- version_conflict (412): If-Match does not match the current version.
|
||||
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
|
||||
- idempotency_key_reused (422): the Idempotency-Key was already used with a different request.
|
||||
|
||||
- precondition_required (428): the operation requires If-Match.
|
||||
|
||||
- rate_limited (429): too many requests; see Retry-After.
|
||||
|
||||
- internal (500): unexpected server error.
|
||||
|
||||
- not_implemented (501): the operation is in the contract but not implemented yet."
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- forbidden
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- idempotency_in_progress
|
||||
- state_conflict
|
||||
- version_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- precondition_required
|
||||
- rate_limited
|
||||
- internal
|
||||
- not_implemented
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: "#/components/schemas/ProblemFieldLocation"
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/salary_from`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/limit` or `/Idempotency-Key`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
Timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
description: UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.
|
||||
examples:
|
||||
- "2026-10-05T09:30:00Z"
|
||||
PageInfo:
|
||||
type: object
|
||||
description: Cursor pagination state of a list response. Lists are ordered by a stable server-defined key. To read the next page, repeat the request with the same filters and `cursor` set to `next_cursor`.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- has_more
|
||||
- next_cursor
|
||||
properties:
|
||||
has_more:
|
||||
type: boolean
|
||||
description: Whether another page follows this one.
|
||||
next_cursor:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: ^[A-Za-z0-9_-]+$
|
||||
description: Opaque cursor of the next page, or null on the last page. Clients must not parse, build, or store it beyond the current listing.
|
||||
parameters:
|
||||
IdempotencyKey:
|
||||
name: Idempotency-Key
|
||||
in: header
|
||||
required: true
|
||||
description:
|
||||
"Client-generated key that makes a retried mutating command safe; a UUID v4 is recommended. The value is sent without quotes. The server scopes the key by caller and operation and fingerprints the request by method, path, and body.
|
||||
|
||||
|
||||
Stored for 24 hours after the first request and replayed with the same status, headers, and body: the final 2xx outcome and final deterministic 4xx business outcomes of the command, such as 404 not_found or 409 state_conflict. A replay does not repeat the side effect.
|
||||
|
||||
|
||||
Not stored, so a retry with the same key is evaluated again: 400 validation_failed, 413, and 415 for the request itself, 401 and 403, 409 idempotency_in_progress, 412 version_conflict and 428 precondition_required (nothing changed; read the resource again and retry), 422 idempotency_key_reused, 429, and every 5xx.
|
||||
|
||||
|
||||
Order of checks: authentication (401), request validation (400, 413, 415), authorization (403), then the key. A stored or running request with a different fingerprint returns 422 idempotency_key_reused before any other key check; a running request with the same fingerprint returns 409 idempotency_in_progress; a stored outcome with the same fingerprint is replayed. Only after that does the server check If-Match, so a retry of a completed change replays its outcome instead of failing on the version it has just changed. After 24 hours the key may be accepted as new."
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
pattern: ^[A-Za-z0-9._:-]+$
|
||||
example: 5f0c6a8e-3b0e-4c47-9f4c-2a8f9e5d7c11
|
||||
IfMatch:
|
||||
name: If-Match
|
||||
in: header
|
||||
required: false
|
||||
description:
|
||||
"Strong entity tag of the resource version the client last read, copied from the ETag response header. An operation that changes a versioned resource says in its own description that it requires If-Match.
|
||||
|
||||
|
||||
On such an operation, a missing If-Match returns 428 precondition_required. An If-Match that does not equal the current ETag returns 412 version_conflict and changes nothing; read the resource again before retrying. Only one strong entity tag is accepted; weak tags, lists, and `*` fail validation with 400. The parameter is optional in the schema so that a missing header reaches the application, which answers 428."
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: ^"[A-Za-z0-9._~-]{1,128}"$
|
||||
example: '"v7"'
|
||||
PageLimit:
|
||||
name: limit
|
||||
in: query
|
||||
required: false
|
||||
description: Maximum number of items in the page. The server may return fewer items even when more remain; use `page.has_more` to detect the end.
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 100
|
||||
default: 20
|
||||
PageCursor:
|
||||
name: cursor
|
||||
in: query
|
||||
required: false
|
||||
description: Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the first page. A malformed or foreign cursor returns 400 with code validation_failed.
|
||||
schema:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 512
|
||||
pattern: ^[A-Za-z0-9_-]+$
|
||||
headers:
|
||||
ETag:
|
||||
description: Strong entity tag of the returned resource version. Send it back in If-Match to change this version.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 130
|
||||
pattern: ^"[A-Za-z0-9._~-]{1,128}"$
|
||||
example: '"v7"'
|
||||
responses:
|
||||
IdempotencyInProgress:
|
||||
description: A request with the same Idempotency-Key and the same fingerprint is still being processed; code idempotency_in_progress. Retry after the original request completes.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
UnprocessableContent:
|
||||
description: The Idempotency-Key was already used with a different request within 24 hours; code idempotency_key_reused. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
PreconditionFailed:
|
||||
description: If-Match does not match the current resource version; code version_conflict. Nothing was changed.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
PreconditionRequired:
|
||||
description: The operation requires If-Match; code precondition_required.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
Problem:
|
||||
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
Reference in new issue
Block a user