2015-01-26 2 views
8

나는 Swagger 편집기 (멋진 도구, 그런데!)에서 여러 줄 리터럴을 얻으려고합니다.거친 편집기에서 다중 행 리터럴?

post: 
    summary: Translate one or more identifiers 
    description: | 
Translate one or more identifiers for one entity into the 
identifiers of another entity. Translate one or more 
identifiers for one entity into the identifiers of another entity. 

    consumes: 
    - application/json 

| 와>, 다른 엔딩 (빈 줄 대 증가 들여 쓰기), 그리고 내가 생각할 수있는 모든 방법으로,하지만 항상 같은 오류 제공과 :

YAML Syntax Error 
Can not read a block mapping entry; a multiline key may not be an implicit 
key at line 24, column 15: consumes:^

내가 문제가 표시 JS-YAML에 대한 버그를 참조 결국 HTML 텍스트 영역이 만들 수있는 Windows 스타일의 새 줄. 내가 YAML을 많이 사용하는 것은 이번이 처음입니다. 그래서 저 자신이 잘못되었거나 Swagger 편집자의 버그입니까?

답변

17

난 당신이 설명 블록에 텍스트를 시작하는 방법 문제라고 생각합니다. 그것은 설명의 오른쪽으로 한 수준 들여 쓰기를해야합니다 여기에 나를 위해 작동 뭔가의 예 :

/{user-id}: 
get: 
    summary: Facebook User 
    description: | 
    Displays all information about a Facebook user, depending on access privileges. Displays all information about a Facebook user, depending on access privileges. 
    parameters: 
    - name: user-id 
     in: path 
     description: The Facebook user ID 
     required: true 
     type: string 

내 실제 코드에서, 설명은 세 줄 깁니다.

+1

좋은 공연 ... 고마워! 그 세부 사항은 YAML 스펙에서 전혀 명확하지 않습니다. – fool4jesus

1

JSON 방식을 추가하고 싶습니다. Swagger Editor에서 순수 JSON을 사용하여 이중 구문 (학습, 디버깅, web documentation 등의 구문 분석) 문제를 방지했습니다. 이중 개행 문자 \n 듯 몇 가지 이유를 들어

"get": { 
    "description": "Hi\n\nThere", 

새로운 라인은 자신감 편집기에 렌더링하는 이상을 위해 필요합니다. 그러나 공식 Uber API YAML demo을 JSON (파일 -> JSON으로 다운로드)으로 내 보낸 경우 결과 JSON에는 여러 줄 리터럴이 표시된 단일 줄 바꿈 문자 만있었습니다. 기묘한.