export function mergeXFernAndResponseExamples(xFernExamples, responseExamples) {
    if (xFernExamples == null) {
        return responseExamples;
    }
    if (responseExamples == null) {
        return xFernExamples;
    }
    const mergedExamples = [];
    for (const example of xFernExamples) {
        let exampleToMerge;
        for (const responseExample of responseExamples) {
            if (example.responseStatusCode === responseExample.responseStatusCode) {
                if (exampleToMerge == null) {
                    exampleToMerge = responseExample;
                }
                else if (example.name === responseExample.name) {
                    exampleToMerge = responseExample;
                    break;
                }
            }
        }
        mergedExamples.push({
            path: example.path ?? exampleToMerge?.path,
            responseStatusCode: example.responseStatusCode ?? exampleToMerge?.responseStatusCode,
            name: example.name ?? exampleToMerge?.name,
            description: example.description ?? exampleToMerge?.description,
            pathParameters: example.pathParameters ?? exampleToMerge?.pathParameters,
            queryParameters: example.queryParameters ?? exampleToMerge?.queryParameters,
            headers: example.headers ?? exampleToMerge?.headers,
            requestBody: example.requestBody ?? exampleToMerge?.requestBody,
            responseBody: example.responseBody ?? exampleToMerge?.responseBody,
            snippets: example.snippets,
        });
    }
    return mergedExamples;
}
