Skip to content

Replacement Macro's not able to access body content #2275

@tonygotskilz

Description

@tonygotskilz

image

We use the code below to replace parameter values found in the JSON before the user hits the try it button. The one noted above does a simple text replacement with a unique string. The issue is that neither one of our macro replacement methods seem to update the actual body text in the UI. In the console it looks as if the text has been replaced but that replaced text is never returned to the UI.

We are currently using:

window.swaggerUi = new SwaggerUi ({
                   parameterMacro: function(operation, parameter) {
                        var str = JSON.stringify(parameter);
                        console.log(parameter);
                        if (str !== undefined && str.length > 0) {
                            str = str.replace(/{replace_with_your_unique_email}/gi, 'Intuit.cto.iam.ius.tests.' + now + '@gmail.com');
                            str = str.replace(/{replace_with_ticket_from_sign_in}/gi, window.THETICKETGLOBAL);
                            str = str.replace(/{replace_with_realmid_from_sign_in}/gi, window.THEREALMIDGLOBAL);
                            str = str.replace(/{replace_with_unique_string}/gi, now + ''+ Math.floor(Math.random() * (99 - 10)) + 1);
                            str = str.replace(/{replace_with_userid_from_sign_in}/gi, window.THEUSERIDGLOBAL);
                        }
                        console.log(str);
                        str = JSON.parse(str);
                        return str;
                    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions