Files
mdm-ordinis/ordinis-rest-api
Zimin A.N. db4f859ef6 feat(api): PATCH /dictionaries/{name}/schema — inline non-breaking field edit (backend #4)
Backend #4 из pending-endpoints brief. Frontend Fields tab inline edit:
кликаешь field row → form показывает только allowed (non-breaking) changes
→ submit → patch component bumps (1.4.0 → 1.4.1) без full DictionaryEditorDialog.

Body:
```json
{
  "expectedHeadVersion": "1.4.0",
  "field": "altitude",
  "changes": { "description": {"ru":"Высота орбиты"}, "minimum": 0 }
}
```

Allowed change keys: description / title / minimum / maximum / enum.
Breaking keys (type/format/x-references/etc) → 422 breaking_change_requires_draft.

Validation:
- minimum tighter than current → 422 validation_failed (могло бы invalidate existing)
- maximum tighter than current → 422 validation_failed
- enum removing existing values → 422 (only additions allowed inline)
- expectedHeadVersion != actual → 409 version_mismatch (optimistic lock)

Implementation:
- PatchSchemaRequest DTO (record).
- SchemaPatchService: gates dict/scope/version, applies whitelisted changes
  on deep-copied JsonNode, bumps patch component via bumpPatchVersion helper
  (semver-safe + fallback для non-semver).
- DictionaryDefinitionController новый @PatchMapping.
- OrdinisException.unprocessableEntity helper (422).

Audit: hooks через existing AuditLogger.definitionUpdated после save.

Tests +10: 4xx scenarios, description update bumps version, enum add ok,
enum remove blocked, minimum expand ok / tighten blocked, version bump
helpers (semver + non-semver fallback).
2026-05-11 23:13:04 +03:00
..