0

Apiary ブループリントの例の中に次の Action セクションを見ました。ユーザーが間違ったパラメーターを渡したときに HTTP ステータス 404 で応答したい。たとえば、ユーザーが /questions/1 の代わりに /questions/xyz を渡した場合などです。ご覧のとおり、/questions の後のパラメーターは数値でなければならないことを定義しましたが、数値の代わりに xyz を渡すと、同じオブジェクトで応答します。

## Questions [/questions/{question_id}]
An Questions object has the following attributes:

+ question - We can put some description for each attribute here.
+ published_at - An ISO8601 date when the question was published.
+ url (string) 
+ choices - An array of Choice objects.

+ Parameters
    + question_id: `1` (number, required) - ID of the Questions in form of an integer

### View an Questions Detail [GET]

+ Response 200 (application/json)

            {
                "question": "Favourite programming language?",
                "published_at": "2014-11-11T08:40:51.620Z",
                "url": "/questions/1",
                "choices": [
                    {   <!-- First Object -->
                        "choice": "Swift",
                        "url": "/questions/1/choices/1",
                        "votes": 2048
                    }
                ]
            }

+ Response 404 (text/plain)

    There is no such a message for the passed id. For example if you pass 'xyz' we expect to show this message.

完全なコードを書いてください。前もって感謝します。

4

1 に答える 1

0

申し訳ありませんが、残念ながら Apiary は、リクエストで渡される本文とパラメーターに基づく条件付き応答をまだサポートしていません。

于 2015-04-24T06:59:43.403 に答える