Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to inject plugins #340

Open
Tsilo opened this issue Apr 6, 2023 · 0 comments
Open

Ability to inject plugins #340

Tsilo opened this issue Apr 6, 2023 · 0 comments

Comments

@Tsilo
Copy link

Tsilo commented Apr 6, 2023

in order to pass preset/plugins we need to add checking in jsTplString so it can push new functions to array

for (var attrname in customOptions) {
    if(attrname == "presets" || attrname == "plugins"){
      swaggerOptions[attrname].push(customOptions[attrname]);
    }else{
      swaggerOptions[attrname] = customOptions[attrname];
    }
  }

here's inject example

var SwaggerHmacAuth = function (system) {
  return {
    statePlugins: {
      spec: {
        wrapActions: {
          setMutatedRequest: (oriAction, system) => (str) => {
            // here, you can hand the value to some function that exists outside of Swagger UI
            console.log('Here is my API definition', str, oriAction, system);
            return oriAction(str); // don't forget! otherwise, Swagger UI won't update
          },
        },
      },
    },
  };
};
let swaggerOptions = {
  presets: [SwaggerHmacAuth],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant