import { getResolvedRefDeep } from "../../operation-code-sample/helpers/get-resolved-ref-deep.js";
import { getExample } from "../../operation-block/helpers/get-example.js";
import { getExampleFromSchema } from "../../operation-code-sample/helpers/get-example-from-schema.js";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
//#region src/v2/blocks/request-block/helpers/get-request-body-example.ts
/**
* Basically getExample + we generate an example from the schema if no example is found
*/
var getExampleFromBody = (requestBody, contentType, exampleKey, requestBodyCompositionSelection) => {
	const content = requestBody.content?.[contentType];
	const example = getExample(requestBody, exampleKey, contentType);
	if (example) return example;
	const schema = getResolvedRef(content?.schema);
	if (!schema) return null;
	const schemaExample = getExampleFromSchema(getResolvedRefDeep(schema), {
		mode: "write",
		compositionSelection: requestBodyCompositionSelection
	}, { schemaPath: ["requestBody"] });
	if (!schemaExample) return null;
	return { value: schemaExample };
};
//#endregion
export { getExampleFromBody };

//# sourceMappingURL=get-request-body-example.js.map