2016-01-11 16 views
0

當我的raml定義指定我的服務的post方法期望json時,生成的post方法正確地使用封裝該json並符合我的模式的對象。RAML formParameters沒有使它發佈方法簽名

但是,並非我已經將post方法更改爲接受application/x-www-form-encoded formParameters,生成的post方法不包含對應於每個參數的參數。我預料到了嗎?

前和工作:

post: 
    description: blah 
    body: 
    application/json: 
    schema: myschema 
    example: !include myexample_request_json.json 

這產生一個POST方法與簽名:

public Response post(final Myrequest myrequest) 

但已經改變了腎錯構瘤到:

post: 
    description: blah 
    body: 
    application/x-www-form-urlencoded: 
     formParameters: 
     myparam1: 
      description: aaa 
      required: true 
      type: string 

我本來期望的產生後處理方法爲:

public Response post(final String myparam1) 

而是它是:

public Response post() 

有人能解釋一下爲什麼嗎?

謝謝

保羅

+0

你用什麼來產生你的方法? –

回答

0

我認爲你錯過了一封信e當你在寫formParameters。請注意,您有formParamters

我建議您檢查API Designer作爲編輯RAML文件的工具。

編輯

因此,它似乎不是一個拼寫錯誤。不幸的是,我無法解釋爲什麼會產生這樣的,但我可以告訴你如何實現它會爲你生成

public Response post(final String myparam1) 

所以,而是採用formParameters和特定類型的內容,你可以用queryParameters去:

post: 
    description: blah   
    queryParameters:  
     myparam1: 
     description: aaa 
     required: true 
     type: string 
+0

對不起 - 拼寫在實際的RAML中是正確的。這是我的帖子,這是錯誤的(現在糾正)。 – Paul

+0

好的,我編輯了我的答案,看看這是否有助於解決問題,或分享您的答案。 – Rufi

+0

謝謝你的迴應。這原來是在生成代碼的maven插件中的一個錯誤。解決該問題解決了該問題。 – Paul

相關問題