feat(api): declare identity contract for registration, verification, and sessions

This commit is contained in:
shira committed 2026-10-05 22:57:19 +03:00
1 parent 197661145e
commit 653f3775f8
86 files changed
+11826 -148

No files matched your search

@@ -630,10 +630,20 @@ func (s *ProblemCode) Decode(d *jx.Decoder) error {
switch ProblemCode(v) {
case ProblemCodeValidationFailed:
*s = ProblemCodeValidationFailed
case ProblemCodeVerificationTokenInvalid:
*s = ProblemCodeVerificationTokenInvalid
case ProblemCodeVerificationTokenExpired:
*s = ProblemCodeVerificationTokenExpired
case ProblemCodeUnauthenticated:
*s = ProblemCodeUnauthenticated
case ProblemCodeInvalidCredentials:
*s = ProblemCodeInvalidCredentials
case ProblemCodeForbidden:
*s = ProblemCodeForbidden
case ProblemCodeEmailNotVerified:
*s = ProblemCodeEmailNotVerified
case ProblemCodeCsrfCheckFailed:
*s = ProblemCodeCsrfCheckFailed
case ProblemCodeNotFound:
*s = ProblemCodeNotFound
case ProblemCodeMethodNotAllowed:
@@ -298,33 +298,46 @@ func (s *Problem) SetErrors(val []ProblemFieldError) {
// - internal (500): unexpected server error.
// - not_implemented (501): the operation is in the contract but not implemented yet.
//
// The enum keeps the public API codes so both contracts share one Problem shape. The identity codes
// verification_token_invalid, verification_token_expired, invalid_credentials, email_not_verified, and
// csrf_check_failed belong to the public API; the ML service never returns them.
// Ref: #/components/schemas/ProblemCode
type ProblemCode string
const (
ProblemCodeValidationFailed ProblemCode = "validation_failed"
ProblemCodeUnauthenticated ProblemCode = "unauthenticated"
ProblemCodeForbidden ProblemCode = "forbidden"
ProblemCodeNotFound ProblemCode = "not_found"
ProblemCodeMethodNotAllowed ProblemCode = "method_not_allowed"
ProblemCodeIdempotencyInProgress ProblemCode = "idempotency_in_progress"
ProblemCodeStateConflict ProblemCode = "state_conflict"
ProblemCodeVersionConflict ProblemCode = "version_conflict"
ProblemCodePayloadTooLarge ProblemCode = "payload_too_large"
ProblemCodeUnsupportedMediaType ProblemCode = "unsupported_media_type"
ProblemCodeIdempotencyKeyReused ProblemCode = "idempotency_key_reused"
ProblemCodePreconditionRequired ProblemCode = "precondition_required"
ProblemCodeRateLimited ProblemCode = "rate_limited"
ProblemCodeInternal ProblemCode = "internal"
ProblemCodeNotImplemented ProblemCode = "not_implemented"
ProblemCodeValidationFailed ProblemCode = "validation_failed"
ProblemCodeVerificationTokenInvalid ProblemCode = "verification_token_invalid"
ProblemCodeVerificationTokenExpired ProblemCode = "verification_token_expired"
ProblemCodeUnauthenticated ProblemCode = "unauthenticated"
ProblemCodeInvalidCredentials ProblemCode = "invalid_credentials"
ProblemCodeForbidden ProblemCode = "forbidden"
ProblemCodeEmailNotVerified ProblemCode = "email_not_verified"
ProblemCodeCsrfCheckFailed ProblemCode = "csrf_check_failed"
ProblemCodeNotFound ProblemCode = "not_found"
ProblemCodeMethodNotAllowed ProblemCode = "method_not_allowed"
ProblemCodeIdempotencyInProgress ProblemCode = "idempotency_in_progress"
ProblemCodeStateConflict ProblemCode = "state_conflict"
ProblemCodeVersionConflict ProblemCode = "version_conflict"
ProblemCodePayloadTooLarge ProblemCode = "payload_too_large"
ProblemCodeUnsupportedMediaType ProblemCode = "unsupported_media_type"
ProblemCodeIdempotencyKeyReused ProblemCode = "idempotency_key_reused"
ProblemCodePreconditionRequired ProblemCode = "precondition_required"
ProblemCodeRateLimited ProblemCode = "rate_limited"
ProblemCodeInternal ProblemCode = "internal"
ProblemCodeNotImplemented ProblemCode = "not_implemented"
)
// AllValues returns all ProblemCode values.
func (ProblemCode) AllValues() []ProblemCode {
return []ProblemCode{
ProblemCodeValidationFailed,
ProblemCodeVerificationTokenInvalid,
ProblemCodeVerificationTokenExpired,
ProblemCodeUnauthenticated,
ProblemCodeInvalidCredentials,
ProblemCodeForbidden,
ProblemCodeEmailNotVerified,
ProblemCodeCsrfCheckFailed,
ProblemCodeNotFound,
ProblemCodeMethodNotAllowed,
ProblemCodeIdempotencyInProgress,
@@ -345,10 +358,20 @@ func (s ProblemCode) MarshalText() ([]byte, error) {
switch s {
case ProblemCodeValidationFailed:
return []byte(s), nil
case ProblemCodeVerificationTokenInvalid:
return []byte(s), nil
case ProblemCodeVerificationTokenExpired:
return []byte(s), nil
case ProblemCodeUnauthenticated:
return []byte(s), nil
case ProblemCodeInvalidCredentials:
return []byte(s), nil
case ProblemCodeForbidden:
return []byte(s), nil
case ProblemCodeEmailNotVerified:
return []byte(s), nil
case ProblemCodeCsrfCheckFailed:
return []byte(s), nil
case ProblemCodeNotFound:
return []byte(s), nil
case ProblemCodeMethodNotAllowed:
@@ -384,12 +407,27 @@ func (s *ProblemCode) UnmarshalText(data []byte) error {
case ProblemCodeValidationFailed:
*s = ProblemCodeValidationFailed
return nil
case ProblemCodeVerificationTokenInvalid:
*s = ProblemCodeVerificationTokenInvalid
return nil
case ProblemCodeVerificationTokenExpired:
*s = ProblemCodeVerificationTokenExpired
return nil
case ProblemCodeUnauthenticated:
*s = ProblemCodeUnauthenticated
return nil
case ProblemCodeInvalidCredentials:
*s = ProblemCodeInvalidCredentials
return nil
case ProblemCodeForbidden:
*s = ProblemCodeForbidden
return nil
case ProblemCodeEmailNotVerified:
*s = ProblemCodeEmailNotVerified
return nil
case ProblemCodeCsrfCheckFailed:
*s = ProblemCodeCsrfCheckFailed
return nil
case ProblemCodeNotFound:
*s = ProblemCodeNotFound
return nil
@@ -311,10 +311,20 @@ func (s ProblemCode) Validate() error {
switch s {
case "validation_failed":
return nil
case "verification_token_invalid":
return nil
case "verification_token_expired":
return nil
case "unauthenticated":
return nil
case "invalid_credentials":
return nil
case "forbidden":
return nil
case "email_not_verified":
return nil
case "csrf_check_failed":
return nil
case "not_found":
return nil
case "method_not_allowed":