How to use the @stoplight/prism-http/mocker/negotiator/NegotiatorHelpers.negotiateOptionsForInvalidRequest function in @stoplight/prism-http

To help you get started, we’ve selected a few @stoplight/prism-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / prism / packages / http / src / mocker / negotiator / HttpOperationOptionsNegotiator.ts View on Github external
public negotiate(resource: IHttpOperation, input: IPrismInput, desiredConfig: IHttpOperationConfig): Promise {
        try {
            const httpRequest = input.data;
            let httpOperationConfig: IHttpOperationConfig;

            if (input.validations.input.length > 0) {
                httpOperationConfig = helpers.negotiateOptionsForInvalidRequest(resource.responses, httpRequest);
            } else {
                httpOperationConfig = helpers.negotiateOptionsForValidRequest(resource, desiredConfig, httpRequest);
            }

            return Promise.resolve({
                httpOperationConfig
            });
        } catch (error) {
            return Promise.resolve({
                error
            });
        }
    }
}