0
votes

In the developer portal that comes from Azure API Management there is a section which contains code examples in different languages on how to call the API.

We would like to remove the JavaScript-section. Is it possible?

Since the code is containing/processing the subscription-key, and it is designed to be executed directly through a web-browser, the subscription-key could potentially be exposed. Thus, we do not want our clients to take this approach. I've tried looking through Microsofts documentation about templates regarding code examples. However, I can only find ways of modifying the actual code snippet, not to remove the actual template.

https://docs.microsoft.com/en-us/azure/api-management/api-management-api-templates#JavaScript

One solution would of course be to rewrite the snippet to become more server-oriented (i.e. Node.js context) but we would prefer to remove the whole template if possible.

2

2 Answers

1
votes

Go for Operation template, at the bottom you will have Samples section similar to:

<div class="panel">
  <h4>{% localized "Documentation|SectionHeadingCodeSamples" %}</h4>
  <div role="tabpanel">
    <ul class="nav nav-tabs" role="tablist">
      {% for sample in samples %}
      ...
      {% endfor %}
    </ul>
    <div class="tab-content tab-content-boxed" title="{% localized "Documentation|TooltipTextDoubleClickToSelectAll" %}">
      {% for sample in samples %}
      ...
      {% endfor %}
    </div>
    ...
</div>

And add a condition around both tab and content:

<div class="panel">
  <h4>{% localized "Documentation|SectionHeadingCodeSamples" %}</h4>
  <div role="tabpanel">
    <ul class="nav nav-tabs" role="tablist">
      {% for sample in samples %}
        {% if sample.title != "JavaScript" %}
        ...
        {% endif %}
      {% endfor %}
    </ul>
    <div class="tab-content tab-content-boxed" title="{% localized "Documentation|TooltipTextDoubleClickToSelectAll" %}">
      {% for sample in samples %}
        {% if sample.title != "JavaScript" %}
        ...
        {% endif %}
      {% endfor %}
    </div>
    ...
  </div>
</div>
0
votes

1) Login to your Azure API Management developer portal as an admin 2) Click the paint brush icon in upper left corner 3) Click Templates 4) Click Javascript.

This opens an editor window at the bottom of your browser, change as needed, save+publish.