メインコンテンツまでスキップ

Exampleオブジェクト

固定フィールド

フィールド名タイプ説明
まとめstring例の簡単な説明。
説明string例の長い説明。CommonMark 構文はリッチ テキスト表現に使用できます (MAY)。
どれでも埋め込まれたリテラルの例。フィールドvalueexternalValueフィールドは相互に排他的です。JSON または YAML で自然に表現できないメディア タイプの例を表現するには、文字列値を使用して例を含め、必要に応じてエスケープします。
外部値stringリテラルの例を指す URI。これにより、JSON または YAML ドキュメントに簡単に含めることができない例を参照する機能が提供されます。フィールドvalueexternalValueフィールドは相互に排他的です。相対参照を解決するためのルールを参照してください。

このオブジェクトは、仕様拡張機能を使用して拡張できます。

すべての場合において、サンプル値は、それに関連付けられた値の型スキーマと互換性があることが期待されます。ツール実装は、互換性を自動的に検証し、互換性がない場合はサンプル値を拒否することを選択してもよい(MAY)。

Exampleオブジェクトの例

リクエスト本文内:

requestBody:  content:    'application/json':      schema:        $ref: '#/components/schemas/Address'      examples:         foo:          summary: A foo example          value: {"foo": "bar"}        bar:          summary: A bar example          value: {"bar": "baz"}    'application/xml':      examples:         xmlExample:          summary: This is an example in XML          externalValue: 'https://example.org/examples/address-example.xml'    'text/plain':      examples:        textExample:           summary: This is a text example          externalValue: 'https://foo.bar/examples/address-example.txt'

パラメータ内:

parameters:  - name: 'zipCode'    in: 'query'    schema:      type: 'string'      format: 'zip-code'    examples:      zip-example:         $ref: '#/components/examples/zip-example'

応答では次のようになります。

responses:  '200':    description: your car appointment has been booked    content:       application/json:        schema:          $ref: '#/components/schemas/SuccessResponse'        examples:          confirmation-success:            $ref: '#/components/examples/confirmation-success'