최근에 만든 RESTful API가 있는데 몇 달 안에 사용하는 방법을 기억하지 못합니다. 나는 Swagger를 사용하여 API를 문서화하기로 결정했지만 미쳐 가고 있습니다.Swagger UI 2.1 스텁 "리소스 목록 가져 오기"
http://editor.swagger.io/을 사용하여 YAML 파일을 만든 다음 Swagger에서 사용할 수있는 JSON 파일로 변환했습니다. Swagger UI에 파일을 넣을 때 fetching resource list: localhost/swagger.json
에 붙어서 콘솔에 Uncaught TypeError: Cannot read property '$ref' of undefined
이라고 표시됩니다.
나는 버전 자신감 UI의 2.1.0-alpha.5을 사용하고 있습니다.
여기 내 사양 파일 : 나는 당신의 스펙을 테스트 한
swagger: '2.0' info: title: TITLE description: BLAH, BLAH, BLAH, ETC version: "1.0b" host: api.example.com schemes: - http basePath: /v1 produces: - application/json paths: /match.json: get: #summary: Match Data description: Used for getting data about a match parameters: - name: id in: query description: The match ID of from a game required: true type: integer format: int32 - name: key in: query description: API key used for authentication. required: true type: string responses: 200: description: Returns match data schema: type: array items: $ref: '#/definitions/MatchData' default: description: Unexpected error schema: $ref: '#/definitions/Error' definitions: MatchData: properties: info: type: integer format: int64 description: General information about the match time: type: integer format: int64 description: Information about the start/end time stats: type: array format: int64 description: Stats about the match Error: required: - errorID - message properties: errorID: type: string description: Error ID. message: type: string description: Information about the error.
어떻게 swagger.json를 호스팅하는 당신이 자신감-UI를 실행하려면 어떻게 – Ron
@webron을 작동합니다은 "swagger.json"파일이 루트에 내 htdocs 디렉토리의 "dist"디렉토리와 루트의 이름도 바뀌 었습니다. 모든 것을 호스트하기 위해 xampp을 사용하고 있습니다. – kevc45