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

#46 - Support transforming swagger variable names to specified Postma… #47

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

davidjgonzalez
Copy link

…n variables.

This adds a new 'transforms' key to the options object in the format:

this.options = {
   transforms: {
        header: {
            '<SWAGGER HEADER NAME>': '<POSTMAN REPLACEMENT>',
       }, path: {
            '<SWAGGER PATH VARIABLE NAME>': '<POSTMAN REPLACEMENT>',
      }, formData: {
            '<SWAGGER FORMDATA VARIABLE NAME>': '<POSTMAN REPLACEMENT>',
      }, body: {
            '<SWAGGER BODY VARIABLE NAME>': '<POSTMAN REPLACEMENT>',
      }
   }
}

The <POSTMAN REPLACEMENT> must contain the wrapping double-curly braces ({{...}}). The <POSTMAN REPLACEMENT> may contain any other hardcoded text/values as well. For instance, a common need for this is setting an Authorization HTTP header, that requires a Bearer prefix, for example:

this.options = {
   transforms: {
        header: {
           'Authorization': 'Bearer {{ACCESS_TOKEN}}'
        }
   }
}

An example initializing the Swagger2Postman converter w/ transform parameters is as follows:

 converter = new Swagger2Postman({
                transforms: {
                    header: {
                        'api-key': '{{API_KEY}}',
                        'Authorization': 'Bearer {{ACCESS_TOKEN}}',
                    },
                    path: {
                        'ownerId': '{{OWNER_ID}}'
                    }
                }
            })

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

Successfully merging this pull request may close these issues.

1 participant