2014-11-16 2 views
1

API 청사진에서 주어진 끝점에 대해 가능한 응답 집합을 정의 할 수 있습니까?API 청사진에서 주어진 끝점에 대해 여러 응답

예를 들어/movie/{id}와 같은 끝 점이있는 경우 모의 서버에서 영화/비디오/1 또는 GET/영화를 볼 수 있도록 동영상 레코드 세트를 정의하고 싶습니다./2 또는 GET/movie/3와 관련 레코드를 가져옵니다.

내가 본 모든 예제는 단지 하나의 가능한 응답을 정의하는 것처럼 보입니다.

답변

0

단일 동작을 사용하여이를 시뮬레이트 할 수는 없지만 해결 방법이 있습니다. 당신이 /movie/2 치면

FORMAT: 1A 

# Multi 

## GET /movie/1 

+ Response 200 (application/json) 

     { "id": 1, "title": "First" } 

## GET /movie/2 

+ Response 200 (application/json) 

     { "id": 2, "title": "Second" } 

## GET /movie/3 

+ Response 200 (application/json) 

     { "id": 3, "title": "Third" } 

## GET /movie/{id} 

+ Parameters 
    + id (required, number, `42`) ... Blah. 

+ Response 200 (application/json) 

     { "id": 42, "title": "First" } 

이제, 모의 서버는 적절한 응답을 보냅니다. 감사.

0

당신은 다음과 같이 여러 요청 블록을 추가 할 수 있습니다

### Register [POST] 
Registers an account 

+ Request Already existing username 

    + Body 

      { 
       "app": 3, 
       "username": "already-existing-username", 
       "password": "password" 
      } 

+ Response 200 (application/json) 

    + Body 

      { 
       "success": false, 
       "error": "The username specified is already registered to an account.", 
       "error_field": "username" 
      } 

+ Request Invalid password 

    + Body 

      { 
       "app": 3, 
       "username": "username", 
       "password": "password" 
      } 

+ Response 200 (application/json) 

    + Body 

      { 
       "success": false, 
       "error": "Please supply a valid password.", 
       "error_field": "password" 
      } 

당신은이 in the official documentation

을 찾을 수 있습니다
관련 문제