---
schema_version: "1"
id: b9d5dd087980599fe7fa5f73aca95bc77ea372132f3b440e24bb4bb25c58f3b9
title: Anypoint DataGraph API 拡張機能リファレンス
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/datagraph/api-extensions.md
canonical_url: https://docs.mulesoft.com/jp/datagraph/api-extensions
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 848da97f08611970f47b6a33f07c486de3653bf22dde5f441e28a3547eed9bef
description: MuleSoft Documentation Site
latest: true
---
# Anypoint DataGraph API 拡張機能リファレンス

このガイドでは、DataGraph の API 拡張機能を定義します。

## [](#オブジェクト種別拡張機能)オブジェクト種別拡張機能

この拡張機能により、オブジェクト種別に主キーがあり、リファレンスまたは拡張機能として使用できることがマークされます。

この拡張機能は、​`ObjectType`​ に適用されます。

### [](#構造)構造

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">オブジェクト種別をエンティティとしてマークします。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity.key</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">空にできない配列。各項目は、エンティティのキーである項目を参照する必要があります。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例)OAS の例

```copy
components:
  schemas:
    Customer:
  	x-entity:
    	  key: [id]
  	properties:
    	  name:
          type: string
    	  email:
          type: string
    	  id:
          type: string
    	  ...
```

### [](#raml-の例)RAML の例

```copy
types:
  Customer:
    (dg.entity):
      key: [id]
    properties:
    	name:
        type: string
    	email:
        type: string
    	id:
        type: string
    	...
```

## [](#エンティティリファレンス)エンティティリファレンス

この拡張機能により、1 つの種別から別の種別への DataGraph ​_リンク_​が生成されます。リンクは、同じ API 仕様で定義されない種別にできます。

この拡張機能は、​`ObjectType`​ に適用されます。

### [](#構造-2)構造

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-reference</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">オブジェクトの配列</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">すべてのリファレンスのリスト。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-reference.[n].name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">参照される種別の名前。API に含まれる場合も含まれない場合もあります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-reference.[n].fieldName</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">この種別について作成される新しい項目の名前。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-reference.[n].keyMapping</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">マップのキーはこの種別の項目を表しており、値は参照される種別のキーを表しています。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例-2)OAS の例

```copy
components:
  Schemas:
    Order:
    	x-entity-reference:
        - name: Customer
          fieldName: customer
          keyMapping:
            customerId: id
        - name: Store
          fieldName: store
          keyMapping:
            storeId: id
      properties:
    	  orderItems:
          ...
    	  customerId:
          type: string
    	  storeId:
          type: string
    Customer:
  	x-entity:
    	  key: [id]
  	properties:
    	  name:
          type: string
    	  email:
          type: string
    	  id:
          type: string
    Store:
  	x-entity:
    	  key: [id]
  	properties:
    	  name:
          type: string
    	  id:
          type: string
    	  ...
```

### [](#raml-の例-2)RAML の例

```copy
types:
  Order:
    (dg.entity-reference):
      - name: Customer
        fieldName: customer
        keyMapping:
          customerId: id
      - name: Store
        fieldName: store
        keyMapping:
          storeId: id
    properties:
    	orderItems:
        ...
    	customerId:
        type: string
    	storeId:
        type: string
  Customer:
    (dg.entity):
      key: [id]
    properties:
    	name:
        type: string
    	email:
        type: string
    	id:
        type: string
    	...
  Store:
    (dg.entity):
      key: [id]
    properties:
    	name:
        type: string
    	id:
        type: string
```

## [](#エンティティプロバイダー)エンティティプロバイダー

この拡張機能では、エンドポイントが ID によってエンティティのインスタンスを返すとマークします。 DataGraph では、これは​_デフォルトのクエリ方法_​です。

この拡張機能は、GET 操作に適用されます。

### [](#構造-3)構造

対象は操作で暗黙的であるため、指定されません。

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-provider</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">エンドポイントがエンティティインスタンスを返すとマークします。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>entity-reference.keyMapping</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">マップのキーはこの操作のパラメーターを表しており、値は対象種別のキーを表しています。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例-3)OAS の例

```copy
Schemas:
    Customer:
  	x-entity:
    	  key: [id]
  	properties:
    	  name:
          type: string
    	  email:
          type: string
    	  1:
          type: string
    	  ...
paths:
  "/customers/{customerId}":
    get:
  	x-entityProvider:
    	  keyMapping:
          customerId: id
  	parameters:
    	  - in: query
          name: summaryView
          default: true
          schema:
          type: boolean
  	...
  	responses:
    	'200':
         content:
            application/json:
          	  schema:
            	$ref: "#/components/schemas/Customer"
```

### [](#raml-の例-3)RAML の例

```copy
types:
  Customer:
    (dg.entity):
      key: [id]
    properties:
    	name:
        type: string
    	email:
        type: string
    	id:
        type: string
    	…

/customer/{customerId}:
  uriParameters:
    customerId: string
  get:
    (dg.entityProvider):
      keyMapping:
        customerId: id
    responses:
      200:
        application/json:
          body: Customer
```

## [](#http-メソッドの上書き)HTTP メソッドの上書き

この拡張機能を使用して、POST メソッドを GET メソッドとして扱います。この拡張機能では、POST メソッドを変異ではなくクエリ操作に変換します。

この拡張機能は、操作に適用されます。

### [](#構造-4)構造

対象は操作で暗黙的であるため、指定されません。

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>http-method-override</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">上書きされる操作をマークします。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>http-method-override.method</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">元の操作を上書きするために使用される HTTP メソッド。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例-4)OAS の例

```copy
paths:
  "/customers":
    post:
  	x-http-method-override:
          method: get
  	responses:
    	'200':
         content:
            application/json:
          	  schema:
                type: array
                items:
                  $ref: "#/components/schemas/Customer"
```

### [](#raml-の例-4)RAML の例

```copy
/customers:
  post:
    (dg.http-method-override):
      method: get
    responses:
      200:
        body:
          application/json:
            type: Customer[]
```

## [](#datagraph-固有の拡張機能)DataGraph 固有の拡張機能

メインのアノテーション ​`datagraph`​ を異なるドメインで同じ名前にすることはできません。そのため、操作、種別、オブジェクトプロパティのアノテーションではポストフィックスを使用します。

- 操作: -method
- 種別: -type
- オブジェクトプロパティ: -field

### [](#非表示)非表示

この拡張機能を使用して、要素を非表示とマークします。非表示の要素は統合スキーマに表示されず、DataGraph ではどのクエリでも非表示の要素が返されません。

この拡張機能は、以下に適用されます。

- 操作
- 任意の種別
- オブジェクトプロパティ

### [](#構造-5)構造

対象は操作で暗黙的であるため、指定されません。

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>datagraph</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">DataGraph 固有のアノテーションのコンテナ。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>datagraph.hide</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Boolean (ブール)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code>​ の場合、要素は統合スキーマで非表示になります。​<code>false</code>​ の場合、要素は非表示にならず、アノテーションを設定しなかった場合と同じ結果が得られます。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例-5)OAS の例

```copy
components:
  Schemas:
    Customer:
  	x-datagraph:
    	  hide: true
  	properties:
    	  name:
          type: string
    	  email:
          type: string
  	    x-datagraph:
    	      hide: true
    	  id:
          type: string
    	  ...
paths:
  "/customers/{customerId}":
    get:
  	x-datagraph:
    	  hide: true
  	parameters:
    	  - in: query
          name: summaryView
          default: true
          schema:
          type: boolean
  	...
  	responses:
    	'200':
         content:
            application/json:
          	  schema:
            	$ref: "#/components/schemas/Customer"
```

### [](#raml-の例-5)RAML の例

```copy
types:
  Customer:
    (dg.datagraph):
      hide: true
    properties:
    	name:
        type: string
    	email:
        type: string
        (dg.datagraph):
          hide: true
    	id:
        type: string
    	…

/customer/{customerId}:
  uriParameters:
    customerId: string
  get:
    (dg.datagraph):
      hide: true
    responses:
      200:
        application/json:
          body: Customer
```

## [](#名前)名前

この拡張機能を使用して、統合スキーマの要素に特定の名前を定義するなど、DataGraph で要素の目的の名前を設定します。この拡張機能を使用して、基礎となる API を変更することなく、さまざまな API の種別を統合できます。

この拡張機能は、以下に適用されます。

- 操作
- 任意の種別
- オブジェクトプロパティ

### [](#構造-6)構造

対象は操作で暗黙的であるため、指定されません。

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>datagraph</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Map (マップ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">DataGraph 固有のアノテーションのコンテナ。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>datagraph.name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">DataGraph の要素の目的の名前。可能であれば、有効な名前にパターンを使用してください。</p></td>
</tr>
</tbody>
</table>

### [](#oas-の例-6)OAS の例

```copy
components:
  Schemas:
    Customer:
  	x-datagraph:
    	  name: SalesCustomer
  	properties:
    	  name:
          type: string
    	  e-mail:
          type: string
  	    x-datagraph:
    	      name: email
    	  id:
          type: string
    	  ...
paths:
  "/customers/{customerId}":
    get:
  	x-datagraph:
    	  name: getCustomer
  	parameters:
    	  - in: query
          name: summaryView
          default: true
          schema:
          type: boolean
  	...
  	responses:
    	'200':
         content:
            application/json:
          	  schema:
            	$ref: "#/components/schemas/Customer"
```

### [](#raml-の例-6)RAML の例

```copy
types:
  Customer:
    (dg.datagraph):
      name: SalesCustomer
    properties:
    	name:
        type: string
    	e-mail:
        type: string
          (dg.datagraph):
            name: email
    	id:
        type: string
    	…

/customer/{customerId}:
  uriParameters:
    customerId: string
  get:
    (dg.datagraph):
      name: getCustomer
    responses:
      200:
        application/json:
          body: Customer
```

## [](#関連情報)関連情報

- [Anypoint Platform DataGraph CLI および API 拡張機能の使用](https://docs.mulesoft.com/jp/datagraph/overview-cli-extensions)
- [Anypoint CLI DataGraph コマンドリファレンス](https://docs.mulesoft.com/jp/datagraph/datagraph-cli)