2017-09-21 8 views
0

그래서 저는 전문가는 아니지만, 모든 시스템에서 JSON 또는 YAML을 사용하여 API의 모든 종점을 정의해야합니다.스칼라 소스 코드 (http4s)에서 Swagger/OpenAPI 사양을 생성하십시오.

제 질문은 : 실제 소스 코드를 기반으로 이러한 사양 파일을 생성하는 방법을 알고 있습니까? 속성을 추가하거나 약간 다른 결과를 반환하기 시작할 때 끝점 코드 & 설명서를 동기화 상태로 유지하는 것이 매우 어렵 기 때문에 묻습니다. 이 코드가있을 때

그래서 (http4s & RhoService 사용) :

object HelloWorld { 
    val service = new RhoService { 
    GET/"hello"/'name |>> { name: String => 
     Ok(Json.obj("message" -> Json.fromString(s"Hello, ${name}"))) 
    } 
    } 
} 

은 어떤 방법 : 그것은 잘 문서화되어 있지 않습니다

/hello/{name}: 
    get: 
     tags: 
     - "HelloWorld" 
     summary: "" 
     description: "" 
     operationId: "getHellobyName" 
     produces:   
     - "application/json" 
     parameters: 
     - name: "name" 
     in: "path" 
     description: "" 
     required: true 
     type: "string" 
     responses: 
     200: 
      description: "successful operation" 
      schema: 
      $ref: "#/definitions/Hello"   
     security: 
     - api_key: [] 

답변