共用方式為


Azure API 管理中的產品範本

Azure API 管理提供您能夠使用一組可設定內容的範本來自訂開發人員入口網站頁面的內容。 使用 DotLiquid 語法和您選擇的編輯器,例如 適用於設計工具的 DotLiquid,以及一組提供的當地語系化 字串資源Glyph 資源,以及 頁面控件,您可以彈性地使用這些範本來設定頁面的內容。

本節中的範本可讓您自定義開發人員入口網站中產品頁面的內容。

備註

範例預設範本會包含在下列檔中,但由於持續改善,可能會有所變更。 您可以在開發人員入口網站中瀏覽至所需的個別範本,以檢視實時默認範本。 如需使用範本的詳細資訊,請參閱 如何使用範本自定義 API 管理開發人員入口網站。

備註

下列檔內容與已淘汰的開發人員入口網站有關。 您可以照舊繼續使用,直到其在 2023 年 10 月淘汰,屆時便會將其從所有 API 管理服務中移除。 已被取代的入口網站只會接收重要的安全性更新。 如需詳細資訊,請參閱下列文章:

可用性

這很重要

這項功能可用於 API 管理的進階標準基本開發人員層。

如需 v2 層的功能可用性(預覽),請參閱 v2 層概觀

產品清單

產品清單範本可讓您在開發人員入口網站中自定義產品清單頁面的本文。

產品清單

默認範本

<search-control></search-control>  
<div class="row">  
    <div class="col-md-9">  
        <h2>{% localized "ProductsStrings|PageTitleProducts" %}</h2>  
    </div>  
</div>  
<div class="row">  
    <div class="col-md-12">  
	{% if products.size > 0 %}  
	<ul class="list-unstyled">  
	{% for product in products %}  
		<li>  
			<h3><a href="/products/{{product.id}}">{{product.title}}</a></h3>  
			{{product.description}}  
		</li>	  
	{% endfor %}  
	</ul>  
	<paging-control></paging-control>  
	{% else %}  
	{% localized "CommonResources|NoItemsToDisplay" %}  
	{% endif %}  
	</div>  
</div>  

控制項

範本 Product list 可以使用下列 頁面控件

資料模型

財產 類型 說明
尋呼 頁面調度 實體。 產品集合的分頁資訊。
篩選 篩選 實體。 產品清單頁面的篩選資訊。
產品 Product 實體的集合。 當前用戶可見的產品。

範例範本資料

{  
    "Paging": {  
        "Page": 1,  
        "PageSize": 10,  
        "TotalItemCount": 2,  
        "ShowAll": false,  
        "PageCount": 1  
    },  
    "Filtering": {  
        "Pattern": null,  
        "Placeholder": "Search products"  
    },  
    "Products": [  
        {  
            "Id": "56f9445ffaf7560049060001",  
            "Title": "Starter",  
            "Description": "Subscribers will be able to run 5 calls/minute up to a maximum of 100 calls/week.",  
            "Terms": "",  
            "ProductState": 1,  
            "AllowMultipleSubscriptions": false,  
            "MultipleSubscriptionsCount": 1  
        },  
        {  
            "Id": "56f9445ffaf7560049060002",  
            "Title": "Unlimited",  
            "Description": "Subscribers have completely unlimited access to the API. Administrator approval is required.",  
            "Terms": null,  
            "ProductState": 1,  
            "AllowMultipleSubscriptions": false,  
            "MultipleSubscriptionsCount": 1  
        }  
    ]  
}  

產品

產品範本可讓您在開發人員入口網站中自訂產品頁面的內容。

開發人員入口網站產品頁面

默認範本

<h2>{{Product.Title}}</h2>  
<p>{{Product.Description}}</p>  
  
{% assign replaceString0 = '{0}' %}  
  
{% if Limits and Limits.size > 0 %}  
<h3>{% localized "ProductDetailsStrings|WebProductsUsageLimitsHeader"%}</h3>  
<ul>  
  {% for limit in Limits %}  
  <li>{{limit.DisplayName}}</li>  
  {% endfor %}  
</ul>  
{% endif %}  
  
{% if apis.size > 0 %}  
<p>  
  <b>  
    {% if apis.size == 1 %}  
    {% capture apisCountText %}{% localized "ProductDetailsStrings|TextblockSingleApisCount" %}{% endcapture %}  
    {% else %}  
    {% capture apisCountText %}{% localized "ProductDetailsStrings|TextblockMultipleApisCount" %}{% endcapture %}  
    {% endif %}  
  
    {% capture apisCount %}{{apis.size}}{% endcapture %}  
    {{ apisCountText | replace : replaceString0, apisCount }}  
  </b>  
</p>  
  
<ul>  
  {% for api in Apis %}  
  <li>  
    <a href="/docs/services/{{api.Id}}">{{api.Name}}</a>  
  </li>  
  {% endfor %}  
</ul>  
{% endif %}  
  
{% if subscriptions.size > 0 %}  
<p>  
  <b>  
    {% if subscriptions.size == 1 %}  
    {% capture subscriptionsCountText %}{% localized "ProductDetailsStrings|TextblockSingleSubscriptionsCount" %}{% endcapture %}  
    {% else %}  
    {% capture subscriptionsCountText %}{% localized "ProductDetailsStrings|TextblockMultipleSubscriptionsCount" %}{% endcapture %}  
    {% endif %}  
  
    {% capture subscriptionsCount %}{{subscriptions.size}}{% endcapture %}  
    {{ subscriptionsCountText | replace : replaceString0, subscriptionsCount }}  
  </b>  
</p>  
  
<ul>  
  {% for subscription in subscriptions %}  
  <li>  
    <a href="/developer#{{subscription.Id}}">{{subscription.DisplayName}}</a>  
  </li>  
  {% endfor %}  
</ul>  
{% endif %}  
{% if CannotAddBecauseSubscriptionNumberLimitReached %}  
<b>{% localized "ProductDetailsStrings|TextblockSubscriptionLimitReached" %}</b>  
{% elsif CannotAddBecauseMultipleSubscriptionsNotAllowed == false %}  
<subscribe-button></subscribe-button>  
{% endif %}  

控制項

範本 Product list 可以使用下列 頁面控件

資料模型

財產 類型 說明
產品 產品 指定的產品。
開發者是否訂閱 布爾值 目前使用者是否訂閱此產品。
訂閱狀態 數字 訂閱的狀態。 可能的狀態為:

- 0 - suspended – 訂用帳戶遭到封鎖,訂閱者無法呼叫產品的任何 API。
- 1 - active – 訂用帳戶為使用中狀態。
- 2 - expired – 訂用帳戶已達到到期日且已停用。
- 3 - submitted – 開發人員已提出訂用帳戶要求,但尚未核准或拒絕。
- 4 - rejected – 系統管理員已拒絕訂用帳戶要求。
- 5 - cancelled – 開發人員或系統管理員已取消訂用帳戶。
限制 陣列 這個屬性已被取代,不應使用。
已啟用委派訂閱 布爾值 是否為此訂用帳戶啟用 委派
委託訂閱網址 字符串 如果已啟用委派,則委派的訂用帳戶 URL。
是否同意 布爾值 如果產品具有條款,則目前使用者是否同意條款。
訂閱 訂閱摘要實體的集合。 產品的訂閱。
Apis API 實體的集合。 此產品中的 API。
無法新增,因為已達到訂閱數量限制 布爾值 目前使用者是否符合訂閱限制以訂閱此產品。
無法新增,因為不允許多重訂閱 布爾值 目前使用者是否有資格訂閱此產品,不論是否允許多個訂用帳戶。

範例範本資料

{  
    "Product": {  
        "Id": "56f9445ffaf7560049060001",  
        "Title": "Starter",  
        "Description": "Subscribers will be able to run 5 calls/minute up to a maximum of 100 calls/week.",  
        "Terms": "",  
        "ProductState": 1,  
        "AllowMultipleSubscriptions": false,  
        "MultipleSubscriptionsCount": 1  
    },  
    "IsDeveloperSubscribed": true,  
    "SubscriptionState": 1,  
    "Limits": [],  
    "DelegatedSubscriptionEnabled": false,  
    "DelegatedSubscriptionUrl": null,  
    "IsAgreed": false,  
    "Subscriptions": [  
        {  
            "Id": "56f9445ffaf7560049070001",  
            "DisplayName": "Starter  (default)"  
        }  
    ],  
    "Apis": [  
        {  
            "id": "56f9445ffaf7560049040001",  
            "name": "Echo API",  
            "description": null,  
            "serviceUrl": "http://echoapi.cloudapp.net/api",  
            "path": "echo",  
            "protocols": [  
                2  
            ],  
            "authenticationSettings": null,  
            "subscriptionKeyParameterNames": null  
        }  
    ],  
    "CannotAddBecauseSubscriptionNumberLimitReached": false,  
    "CannotAddBecauseMultipleSubscriptionsNotAllowed": true  
}  

後續步驟

如需使用範本的詳細資訊,請參閱 如何使用範本自定義 API 管理開發人員入口網站。