/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 2b10a2765805
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type Option = string | boolean;

export type FetchChatCompletionFieldOptionsResponse = {
  options?: Array<string | boolean | null> | null | undefined;
};

/** @internal */
export const Option$inboundSchema: z.ZodType<Option, unknown> = smartUnion([
  z.string(),
  z.boolean(),
]);

export function optionFromJSON(
  jsonString: string,
): SafeParseResult<Option, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Option$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Option' from JSON`,
  );
}

/** @internal */
export const FetchChatCompletionFieldOptionsResponse$inboundSchema: z.ZodType<
  FetchChatCompletionFieldOptionsResponse,
  unknown
> = z.object({
  options: z.nullable(
    z.array(z.nullable(smartUnion([z.string(), z.boolean()]))),
  ).optional(),
});

export function fetchChatCompletionFieldOptionsResponseFromJSON(
  jsonString: string,
): SafeParseResult<
  FetchChatCompletionFieldOptionsResponse,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      FetchChatCompletionFieldOptionsResponse$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'FetchChatCompletionFieldOptionsResponse' from JSON`,
  );
}
