import { SkyrampClient } from "@skyramp/skyramp";
import { IsValidKeyValueList } from "./utils.js";
// Analyze OpenAPI to check for required path params
export async function analyzeOpenAPIWithGivenEndpoint(apiSchemaInput, uriInput, pathParamsInput) {
    const client = new SkyrampClient();
    const analyzeOpenapiOptions = {
        apiSchema: apiSchemaInput,
        uri: uriInput,
    };
    const pathParamRequired = await client.analyzeOpenapi(analyzeOpenapiOptions);
    if (IsValidKeyValueList(pathParamRequired)) {
        const requiredPathParams = pathParamRequired
            ? pathParamRequired.split(",").map((p) => p.trim())
            : [];
        const providedPathParams = pathParamsInput
            ? pathParamsInput.split(",").map((param) => param.split("=")[0].trim())
            : [];
        // Find missing path parameters by comparing keys
        const missingPathParams = requiredPathParams.filter((param) => !providedPathParams.includes(param));
        if (missingPathParams.length > 0) {
            return `${missingPathParams.join(", ")}`;
        }
    }
    return null;
}
