Skip to content

Commit

Permalink
Revert "feat: swagger2idl plugin (#9)"
Browse files Browse the repository at this point in the history
This reverts commit afce6c5.
  • Loading branch information
li-jin-gou authored Oct 16, 2024
1 parent afce6c5 commit ec2463f
Show file tree
Hide file tree
Showing 25 changed files with 13 additions and 4,866 deletions.
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@

English | [中文](README_CN.md)

**Swagger Generate** is a set of plugin tools designed for HTTP and RPC services, supporting the automatic generation of Swagger documentation and integration with Swagger-UI for debugging. Additionally, it provides the ability to convert Swagger documents into Protobuf or Thrift IDL files, simplifying the API development and maintenance process.

This project is compatible with the [CloudWeGo](https://www.cloudwego.io) ecosystem frameworks such as [Cwgo](https://github.com/cloudwego/cwgo), [Hertz](https://github.com/cloudwego/hertz), and [Kitex](https://github.com/cloudwego/kitex). It offers a convenient toolset for developers to automatically generate Swagger documentation, simplifying the API documentation and debugging process.
**Swagger Generate** is a collection of plugins that generate Swagger documentation and provide Swagger-UI access for debugging HTTP and RPC services. This project is compatible with the [CloudWeGo](https://www.cloudwego.io) ecosystem frameworks such as [Cwgo](https://github.com/cloudwego/cwgo), [Hertz](https://github.com/cloudwego/hertz), and [Kitex](https://github.com/cloudwego/kitex). It offers a convenient toolset for developers to automatically generate Swagger documentation, simplifying the API documentation and debugging process.

## Included Plugins

- **[protoc-gen-http-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-rpc-swagger)**: Generates Swagger documentation and provides Swagger UI debugging for HTTP services based on Protobuf.
- **[thrift-gen-http-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-http-swagger)**: Generates Swagger documentation and provides Swagger UI debugging for HTTP services based on Thrift.
- **[protoc-gen-rpc-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/protoc-gen-rpc-swagger)**: Generates Swagger documentation and provides Swagger UI debugging for RPC services based on Protobuf.
- **[thrift-gen-rpc-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-rpc-swagger)**: Generates Swagger documentation and provides Swagger UI debugging for RPC services based on Thrift.
- **[swagger2idl](https://github.com/hertz-contrib/swagger-generate/tree/main/swagger2idl)**: Converts Swagger documents into Protobuf or Thrift IDL files.
- **protoc-gen-http-swagger**: Generates Swagger documentation and provides Swagger UI debugging for HTTP services based on Protobuf.
- **thrift-gen-http-swagger**: Generates Swagger documentation and provides Swagger UI debugging for HTTP services based on Thrift.
- **protoc-gen-rpc-swagger**: Generates Swagger documentation and provides Swagger UI debugging for RPC services based on Protobuf.
- **thrift-gen-rpc-swagger**: Generates Swagger documentation and provides Swagger UI debugging for RPC services based on Thrift.

## Key Advantages

- **Automated Generation**: Supports generating complete Swagger documentation from Protobuf and Thrift files, simplifying API documentation maintenance.
- **Integrated Debugging**: The generated Swagger UI can be used directly for service debugging, supporting both HTTP and RPC modes.
- **Hertz and Kitex Integration**: Provides seamless documentation generation and debugging support for [Hertz](https://github.com/cloudwego/hertz) and [Kitex](https://github.com/cloudwego/kitex).
- **Flexible Annotation Support**: Allows extending the generated Swagger documentation through annotations, supporting OpenAPI annotations such as `openapi.operation`, `openapi.schema`, etc.
- **IDL Conversion**: Supports converting Swagger documents into Protobuf or Thrift IDL files, making it easier for developers to switch between different frameworks.

## Installation

Expand Down Expand Up @@ -103,13 +99,8 @@ func main() {
}
}
```
For more examples, please refer to [kitex_swagger_gen](https://github.com/cloudwego/kitex-examples/tree/main/bizdemo/kitex_swagger_gen) and [hertz_swagger_gen](https://github.com/cloudwego/hertz-examples/tree/main/bizdemo/hertz_swagger_gen).

### Converting Swagger Documents to IDL Files

```sh
swagger2idl -o my_output.proto -oa -a openapi.yaml
```
For more examples, please refer to [kitex_swagger_gen](https://github.com/cloudwego/kitex-examples/tree/main/bizdemo/kitex_swagger_gen) and [hertz_swagger_gen](https://github.com/cloudwego/hertz-examples/tree/main/bizdemo/hertz_swagger_gen).

## More Information

Expand Down
23 changes: 7 additions & 16 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@

[English](README.md) | 中文

**Swagger Generate** 是一组插件工具,专为 HTTP 和 RPC 服务设计,支持自动生成 Swagger 文档,并集成 Swagger-UI 进行调试。此外,它还提供将 Swagger 文档转换为 Protobuf 或 Thrift IDL 文件的功能,简化了 API 开发与维护的流程。

该项目适用于 [CloudWeGo](https://www.cloudwego.io) 生态下的 [Cwgo](https://github.com/cloudwego/cwgo)[Hertz](https://github.com/cloudwego/hertz)[Kitex](https://github.com/cloudwego/kitex) 框架。它提供了一套便捷的工具来帮助开发者自动生成 Swagger 文档,从而简化 API 文档编写及调试过程。
**Swagger Generate** 是一个为 HTTP 和 RPC 服务生成 Swagger 文档及 Swagger-UI 访问调试的插件集合。该项目适用于 [CloudWeGo](https://www.cloudwego.io) 生态下的 [Cwgo](https://github.com/cloudwego/cwgo)[Hertz](https://github.com/cloudwego/hertz)[Kitex](https://github.com/cloudwego/kitex) 框架。它提供了一套便捷的工具来帮助开发者自动生成 Swagger 文档,从而简化 API 文档编写及调试过程。

## 包含的插件

- **[protoc-gen-http-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-rpc-swagger)**:为基于 Protobuf 的 HTTP 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **[thrift-gen-http-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-http-swagger)**:为基于 Thrift 的 HTTP 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **[protoc-gen-rpc-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/protoc-gen-rpc-swagger)**:为基于 Protobuf 的 RPC 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **[thrift-gen-rpc-swagger](https://github.com/hertz-contrib/swagger-generate/tree/main/thrift-gen-rpc-swagger)**:为基于 Thrift 的 RPC 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **[swagger2idl](https://github.com/hertz-contrib/swagger-generate/tree/main/swagger2idl)**:将 Swagger 文档转换为 Protobuf 或 Thrift IDL 文件。
- **protoc-gen-http-swagger**:为基于 Protobuf 的 HTTP 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **thrift-gen-http-swagger**:为基于 Thrift 的 HTTP 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **protoc-gen-rpc-swagger**:为基于 Protobuf 的 RPC 服务生成 Swagger 文档和 Swagger UI 进行调试。
- **thrift-gen-rpc-swagger**:为基于 Thrift 的 RPC 服务生成 Swagger 文档和 Swagger UI 进行调试。

## 项目优势

- **自动化生成**:支持通过 Protobuf 和 Thrift 文件生成完整的 Swagger 文档,简化了 API 文档的维护。
- **集成调试**:生成的 Swagger UI 能直接用于调试服务,支持 HTTP 和 RPC 两种模式。
- **Hertz 和 Kitex 集成**:为 [Hertz](https://github.com/cloudwego/hertz)[Kitex](https://github.com/cloudwego/kitex) 提供了无缝的文档生成和调试支持。
- **灵活的注解支持**:允许通过注解扩展生成的 Swagger 文档内容,支持 `openapi.operation``openapi.schema` 等 OpenAPI 注解。
- **IDL 转换**:支持将 Swagger 文档转换为 Protobuf 或 Thrift IDL 文件,方便开发者在不同框架间切换。

## 安装

Expand Down Expand Up @@ -102,14 +98,9 @@ func main() {
}
}
```
请参考 [kitex_swagger_gen](https://github.com/cloudwego/kitex-examples/tree/main/bizdemo/kitex_swagger_gen)[hertz_swagger_gen](https://github.com/cloudwego/hertz-examples/tree/main/bizdemo/hertz_swagger_gen) 获取更多使用场景示例。

### 将 Swagger 文档转换为 IDL 文件

```sh
swagger2idl -o my_output.proto -oa -a openapi.yaml
```
请参考 [kitex_swagger_gen](https://github.com/cloudwego/kitex-examples/tree/main/bizdemo/kitex_swagger_gen)[hertz_swagger_gen](https://github.com/cloudwego/hertz-examples/tree/main/bizdemo/hertz_swagger_gen) 获取更多使用场景示例。

## 更多信息

请参考各个插件的 README 文档获取更多使用细节。
请参考各个插件的 readme 文档获取更多使用细节。
12 changes: 0 additions & 12 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ const (
DefaultInfoDesc = "API description"
DefaultInfoVersion = "0.0.1"

IDLProto = "proto"
IDLThrift = "thrift"

DocumentOptionServiceType = "service"
DocumentOptionStructType = "struct"

Expand All @@ -103,13 +100,6 @@ const (
DefaultOutputDir = "swagger"
DefaultOutputYamlFile = "openapi.yaml"
DefaultOutputSwaggerFile = "swagger.go"
DefaultProtoFilename = "output.proto"
DefaultThriftFilename = "output.thrift"
OpenapiThriftFile = "openapi.thrift"
ApiProtoFile = "api.proto"
OpenapiProtoFile = "openapi/annotations.proto"
EmptyProtoFile = "google/protobuf/empty.proto"
TimestampProtoFile = "google/protobuf/timestamp.proto"

DefaultServerURL = "http://127.0.0.1:8888"
DefaultKitexAddr = "127.0.0.1:8888"
Expand All @@ -122,6 +112,4 @@ const (

ProtobufValueName = "GoogleProtobufValue"
ProtobufAnyName = "GoogleProtobufAny"
EmptyMessage = "google.protobuf.Empty"
TimestampMessage = "google.protobuf.Timestamp"
)
Loading

0 comments on commit ec2463f

Please sign in to comment.