2017-02-20 16 views
0

私はOpenAPIを初めて使いました。私たちのプラットフォームから支払いを作成するためにPayPalのpayment APIの基本スワッガーファイルを作成するにはいくつかの助けが必要です。 :OAuthはすでに設定されています。PayPal支払いAPIのスワッガーフォーマット

以下

は基本闊歩ファイルですが、私はどこにpaymet request information(すなわち意図、支払者、取引など)を追加するかわからない:editor.swagger上のファイルをテスト

{ 
    "swagger": "2.0", 
    "info": { 
    "description": "this is a payment request to through PayPal", 
    "title": "Swagger PayPal Payment", 
    "version": "1.0.0" 
    }, 
    "host": "api.sandbox.paypal.com", 
    "basePath": "/v1/payments", // 
    "schemes": [ "https" ], 
    "paths": { 
    "/payment": 
    { 
     "post": { 
     "summary": "Creates a payment" 
     "description": "Creates a payment request to Paypal", 
     "parameters": { 

     }, 
     //"intent": "sale", 
     //"payer": 
     //{ 
     // "payment_method": "paypal" 
     //}, 
     //"transactions": [ 
     // { 
     // "amount": { 
     //  "total": "9.00", 
     //  "currency": "EUR" 
     // } 
     // } 
     //], 
     "responses": { 
      "200": { 
      "description": "OK" 
      } 
     } 
     } 
    } 
    } 
} 

、私が取得しますトランザクション、支払人、およびインテントに関する「OBJECT_ADDITIONAL_PROPERTIES」エラー。

+0

誰もがPayPal APIのスワッガーフォーマットファイルを書いていますか? – Jnr

+0

RESTUnitedは良い選択だと思われます。 – Jnr

答えて

1

JSONペイロードは、のパラメータを持つbody parameterと定義されています。このパラメータには、JSONオブジェクトのプロパティを定義するschemaが必要です。 通常、グローバルdefinitionsセクションにオブジェクトスキーマを定義し、$refを使用してオブジェクトスキーマを参照します。

ここには読みやすくするためのYAMLバージョンがあります。 JSONに変換するには、http://editor.swagger.ioに貼り付け、ファイル/ JSONのダウンロードを使用します。

swagger: "2.0" 
info: 
    description: this is a payment request to through PayPal 
    title: Swagger PayPal Payment 
    version: "1.0.0" 

host: api.sandbox.paypal.com 
basePath: /v1/payments 
schemes: [ https ] 

paths: 
    /payment: 
    post: 
     summary: Creates a payment 
     description: Creates a payment request to Paypal 
     parameters: 
     - in: body 
      name: payment 
      required: true 
      schema: 
      $ref: "#/definitions/Payment" # <-------- 
     responses: 
     "200": 
      description: OK 

definitions: 

    # Request body object 
    Payment: 
    type: object 
    properties: 
     intent: 
     type: string 
     payer: 
     $ref: "#/definitions/Payer" 
     transactions: 
     type: array 
     items: 
      $ref: "#/definitions/Transaction" 

    Payer: 
    type: object 
    properties: 
     payment_method: 
     type: string 
     example: paypal 

    Transaction: 
    type: object 
    properties: 
     ... # TODO 
関連する問題