Forum Discussion

polson's avatar
polson
New Contributor
8 years ago

How do we set global values? For template parameters, headers, auth type, and more.

I started a new project, imported a swagger file, and it generated a lot of resources. This is good.

 

But, all my generated resources use and require template parameters, headers, and basic authentication. I can set these values at the method level but it's tedious. Ideally they could be set at the project level. That, or I'm approaching this wrong (this is very much possible!)

 

How can I set default global values for these like I did for the end point? Basically, in psuedo-code:

 

if (resource uses template parameters) {
  if (template parameter not defined) {
    use default global value for this template parameter;
  }
}

 

The same for headers and authentication method. In this case, I want to enable basic auth for all resources. Basically, this means defining all of this in one place rather than 40 (in my case).

 

I set "custom properties" at the project level but this doesn't seem to do anything regarding the above.

 

I'm using the Open Source version :) Thanks!

3 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    polson, first you need to define properties at the project level, e.g. MyVariable.

     

    Then you can insert their values into HTTP headers, message content and other places with the following statement:

     

    ${#Project#MyVariable}

     

    Karel

     

     

    • polson's avatar
      polson
      New Contributor

      Thank you for the response, although I think my question was unclear. I do regret using pseudo-code in my question as I'm hoping to avoid writing code at all. Although if needed, that's okay too.

       

      But, I see how to set global custom properties in the GUI but they don't seem to do what I want. Should those affect template parameters? Or header values? They don't seem to. 

       

      After importing the swagger file, the names for these template parameters and required headers are automagically set but the values are empty. I see how to define them (in the GUI) at the method level, but not project level.