/**
 * Paypal Server SDKLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

import { array, lazy, object, optional, Schema, string } from '../schema';
import { LinkDescription, linkDescriptionSchema } from './linkDescription';

/** The error details. Required for client-side `4XX` errors. */
export interface ErrorDetails {
  /** The field that caused the error. If this field is in the body, set this value to the field's JSON pointer value. Required for client-side errors. */
  field?: string;
  /** The value of the field that caused the error. */
  value?: string;
  /** The location of the field that caused the error. Value is `body`, `path`, or `query`. */
  location?: string;
  /** The unique, fine-grained application-level error code. */
  issue: string;
  /** An array of request-related [HATEOAS links](/api/rest/responses/#hateoas-links) that are either relevant to the issue by providing additional information or offering potential resolutions. */
  links?: LinkDescription[];
  /** The human-readable description for an issue. The description can change over the lifetime of an API, so clients must not depend on this value. */
  description?: string;
}

export const errorDetailsSchema: Schema<ErrorDetails> = object({
  field: ['field', optional(string())],
  value: ['value', optional(string())],
  location: ['location', optional(string())],
  issue: ['issue', string()],
  links: ['links', optional(array(lazy(() => linkDescriptionSchema)))],
  description: ['description', optional(string())],
});
