Url
この要素には、 エンドポイントの詳細 とともに 可能な操作 Urlについて
可能な場所
- 熱 意/ヘルプ/ zest -仕様ファイル/リソース/">リソース
子要素
- 熱 意/ヘルプ/ zest -指定ファイル/url/操作/導入/">操作 必須 繰り返し
属性
| お名前 | タイプ | 説明 |
|---|---|---|
| パス
必須 | 文字列 | Urlのエンドポイント。 |
変数パスの設定
Url の変数パスはしばしば変更されます。たとえば、Url で /API/v1/ユーザー/900000000123 、Id は頻繁に変更されるため、この部分は url パスの変数です。このようなパス変数を設定するには、次のものを使用します。
<url path="/api/v1/users/{userId}">
</url>
ここでは、単一の中括弧内で変数名を定義します。この Url タグの下にあるすべての操作では、指定した名前を使用してパス変数の引数を定義する必要があります。
<url path="/api/v1/users/{userId}">
<operation name="Get User">
<argument name="userId" location="variable"...>.....
</argument>......
</operation>
<operation name="Update User"....>
<argument name="userId" location="variable"...>.....
</argument>......
</operation>
</url>
この例では、パス変数 ( ユーザーId ) を指定し、Url の下の各操作がこの変数を引数として指定することを確認します。
サンプル
シングル操作
次の情報を使用して、旅行リソースの操作を取得するための Url を記述していると仮定します。
success response:
{
"trips": [
{
"trip_name":"Spring Break - John Doe",
"destination": "Bali",
"start_time": "2023-11-13T17:30:00",
"end_time": "2023-11-17T22:30:00",
"no_of_days": 4
},
{
"trip_name":"christmas Break - Diana Williams",
"destination": "London",
"start_time": "2023-12-20T21:30:00",
"end_time": "2023-12-28T09:30:00",
"no_of_days": 7
}
]
}
error response:
{
"code": "INVALID_TOKEN",
"message": "invalid oauth token",
"status": "error"
}
を宣言する必要があります。 熱 意/ヘルプ/ zest -仕様ファイル/リソース構成/導入/#attributes">プライマリ構造 の旅行リソースの 熱 意/ヘルプ/ zest -仕様ファイル/コンポーネント/"> Url を定義する前に
<!-- primary structure of trips resource -->
<structure ref-name="trips" name="trips_data">
<property name="trip_name" type="string"/>
<property name="trip_id" type="long_string"/> <!-- Corrected this tag -->
<property name="destination" type="string"/>
<property name="start_time" type="datetime"/>
<property name="end_time" type="datetime"/>
<property name="no_of_days" type="string"/>
</structure>
<!-- wrapper of the primary structure -->
<structure ref-name="data" name="wrapper">
<property name="trips" type="collections">
<structure-ref name="trips" />
</property>
</structure>
次に、次のように Url を宣言します。
<url path="/travel_bureau/v4/trips">
<operation method="get" name="GET trips" category="read">
<response name="get_success" status="200">
<content>
<encode type="application/json" />
<structure-ref name="data" />
</content>
</response>
<response name="invalid_token" status="401">
<content>
<encode type="application/json" />
<structure>
<property name="code" type="string" values="INVALID_TOKEN"/>
<property name="message" type="string" values="You have used an invalid oauth token." />
<property name="status" type="string" values="error"/>
</structure>
</content>
</response>
</operation>
</url>
複数の操作
トリップリソースの投稿操作と取得操作の両方のUrlを変更することを目指していることを考慮してください。 このシナリオでは、応答を取得は投稿のリクエスト本文として機能します。ただし、 旅行Id 熱 意/ヘルプ/ zest -仕様ファイル/構造/プロパティ/導入/"> . これを達成するには、調整する必要があります。 熱 意/ヘルプ/ zest -仕様ファイル/リソース構成/導入/#attributes">プライマリ構造 一般的なエラーを追加する 熱 意/ヘルプ/ zest -仕様ファイル/url/操作/応答/"> に 熱 意/ヘルプ/ zest -仕様ファイル/コンポーネント/"> このリソースは、両方の操作に対応します。 以下は、旅行リソースの変更されたコンポーネントです。
<components>
<structure ref-name="trips" name="trips_data">
<property name="trip_name" type="string"/>
<property name="trip_id" type="long_string" include-for="Request[],Response[read]"> <!-- include-for attribute is used to neglect the property in CREATE operation -->
<property name="destination" type="string"/>
<property name="start_time" type="datetime"/>
<property name="end_time" type="datetime"/>
<property name="no_of_days" type="string"/>
</structure>
<structure ref-name="data" name="wrapper">
<property name="trips" type="collections">
<structure-ref name="trips" />
</property>
</structure>
<response name="invalid_token" status="401">
<content>
<encode type="application/json" />
<structure>
<property name="code" type="string" values="INVALID_TOKEN"/>
<property name="message" type="string" values="You have used an invalid oauth token."/>
<property name="status" type="string" values="error"/>
</structure>
</content>
</response>
</components>
次の方法で 2 つの異なる操作の Url を定義します。
<url path="/travel_bureau/v4/trips">
<operation method="get" name="GET trips" category="read">
<response name="get_success" status="200">
<content>
<encode type="application/json" />
<structure-ref name="data" />
</content>
</response>
<response-ref name="invalid_token" />
</operation>
<operation method="post" name="POST trips" category="create">
<request-body name="request">
<content>
<encode type="application/json" />
<structure-ref name="data" />
</content>
</request-body>
<response name="post_success" status="201">
<content>
<encode type="application/json" />
<structure name="body">
<property name="code" type="string" values="SUCCESS"/>
<property name="message" type="string" values="Trip Created"/>
<property name="status" type="string" values="success"/>
</structure>
</content>
</response>
<response-ref name="invalid_token" />
</operation>
</url>
Last Updated 2026-02-06 15:55:45 +0530 IST
Yes
No
Send your feedback to us