trpc.group/trpc-go/trpc-cmdline@v1.0.9/util/apidocs/swagger/gen.go (about) 1 // Tencent is pleased to support the open source community by making tRPC available. 2 // 3 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 4 // All rights reserved. 5 // 6 // If you have downloaded a copy of the tRPC source code from Tencent, 7 // please note that tRPC source code is licensed under the Apache 2.0 License, 8 // A copy of the Apache 2.0 License is included in this file. 9 10 // Package swagger provides the ability to manipulate swagger documentation. 11 package swagger 12 13 import ( 14 "trpc.group/trpc-go/trpc-cmdline/descriptor" 15 "trpc.group/trpc-go/trpc-cmdline/params" 16 "trpc.group/trpc-go/trpc-cmdline/util/apidocs" 17 ) 18 19 // GenSwagger provides an external structure used to generate swagger JSON. 20 func GenSwagger(fd *descriptor.FileDescriptor, option *params.Option) error { 21 // Assemble the entire Swagger JSON information. 22 swaggerJSON, err := apidocs.NewSwagger(fd, option) 23 if err != nil { 24 return err 25 } 26 27 return apidocs.WriteJSON(option.SwaggerOut, swaggerJSON) 28 }