wecom openapi
1.0.0
简体中文
이 프로젝트의 목표는 WeCom 문서를 OpenAPI 사양으로 변환하여 다양한 프로그래밍 언어로 클라이언트 코드를 생성할 수 있도록 하는 것입니다. 현재 OpenAPI 사양 버전 3.x를 사용하고 있습니다.
$ npm install
앱이 실행되면 OpenAPI 사양 파일 openapi.yaml
생성됩니다. http://localhost:3000/openapi
열어 Swagger UI를 볼 수 있습니다.
$ npm run start
swagger-codegen은 OpenAPI 사양에서 코드를 생성하는 데 매우 널리 사용되는 도구입니다. 하지만 Golang을 사용한다면 go-swagge를 권장합니다.
go-swagge는 OpenAPI 사양 2.0을 기반으로 하기 때문에 버전을 다운그레이드해야 합니다.
$ npm install -g api-spec-converter
$ api-spec-converter --from=openapi_3 --to=swagger_2 --syntax=yaml --order=alpha ./openapi.yaml > swagger.yaml
그런 다음 swagger.yaml
파일에서 Golang 코드를 생성합니다.
$ brew tap go-swagger/go-swagger
$ brew install go-swagger
$ mkdir wecom-api && cd wecom-api
# NOTE: you need run go mod init to create a go.mod file
$ go mod init wecom-api
$ swagger generate client -f swagger.yaml -t wecom-api
이 프로젝트는 NestJS의 Swagger 통합을 기반으로 합니다. 자세한 내용은 OpenAPI(NestJS)를 참고하세요.
nest g --no-spec controller department
일반적으로 DTO와 응답은 서로 다른 클래스에서 선언됩니다.
nest g --no-spec class department/Department
@ApiProperty({
required: false,
type: 'string',
isArray: true,
maxItems: 100,
example: '["abel"]',
description: 'user id list, max length is 100',
})
userid_list: string[];
required
, type
이 필수입니다.description
, example
권장。 @ApiOperation({
operationId: 'getGroupChat',
summary: 'Get user group detail',
description: 'Get user group detail',
externalDocs: {
url: 'https://developer.work.weixin.qq.com/document/path/92122',
},
})
operationId
필수, 고유, 생성 코드의 함수 이름입니다.summary
필수externalDocs
WeCom 공식 문서 링크. 먼저 API 호출을 승인하려면 access_token
가져와야 합니다.
브라우저에 CORS 문제가 있어서 wx-work에 직접 액세스할 수 없습니다. 그래서 우리는 당신을 위해 프록시를 만들었습니다. 액세스하려면 http://localhost:3000/cgi-bin
사용하세요.