/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";

export type JsonSchema = {
  name: string;
  description?: string | null | undefined;
  schemaDefinition: { [k: string]: any };
  strict?: boolean | undefined;
};

/** @internal */
export type JsonSchema$Outbound = {
  name: string;
  description?: string | null | undefined;
  schema: { [k: string]: any };
  strict?: boolean | undefined;
};

/** @internal */
export const JsonSchema$outboundSchema: z.ZodType<
  JsonSchema$Outbound,
  z.ZodTypeDef,
  JsonSchema
> = z.object({
  name: z.string(),
  description: z.nullable(z.string()).optional(),
  schemaDefinition: z.record(z.any()),
  strict: z.boolean().optional(),
}).transform((v) => {
  return remap$(v, {
    schemaDefinition: "schema",
  });
});

export function jsonSchemaToJSON(jsonSchema: JsonSchema): string {
  return JSON.stringify(JsonSchema$outboundSchema.parse(jsonSchema));
}
