Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
agentchat
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟@五瓣科技
agentchat
Commits
102348d1
Commit
102348d1
authored
May 30, 2025
by
Wade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add swagger
parent
cc267d3b
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
5 deletions
+143
-5
docs.go
docs/docs.go
+36
-0
swagger.json
docs/swagger.json
+7
-0
swagger.yaml
docs/swagger.yaml
+24
-0
go.mod
go.mod
+15
-5
go.sum
go.sum
+42
-0
main.go
main.go
+19
-0
No files found.
docs/docs.go
0 → 100644
View file @
102348d1
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package
docs
import
"github.com/swaggo/swag"
const
docTemplate
=
`{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var
SwaggerInfo
=
&
swag
.
Spec
{
Version
:
""
,
Host
:
""
,
BasePath
:
""
,
Schemes
:
[]
string
{},
Title
:
""
,
Description
:
""
,
InfoInstanceName
:
"swagger"
,
SwaggerTemplate
:
docTemplate
,
LeftDelim
:
"{{"
,
RightDelim
:
"}}"
,
}
func
init
()
{
swag
.
Register
(
SwaggerInfo
.
InstanceName
(),
SwaggerInfo
)
}
docs/swagger.json
0 → 100644
View file @
102348d1
{
"swagger"
:
"2.0"
,
"info"
:
{
"contact"
:
{}
},
"paths"
:
{}
}
\ No newline at end of file
docs/swagger.yaml
0 → 100644
View file @
102348d1
openapi
:
3.0.4
info
:
title
:
Sample API
description
:
Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version
:
0.1.9
servers
:
-
url
:
http://api.example.com/v1
description
:
Optional server description, e.g. Main (production) server
-
url
:
http://staging-api.example.com
description
:
Optional server description, e.g. Internal staging server for testing
paths
:
/users
:
get
:
summary
:
Returns a list of users.
description
:
Optional extended description in CommonMark or HTML.
responses
:
"
200"
:
# status code
description
:
A JSON array of user names
content
:
application/json
:
schema
:
type
:
array
items
:
type
:
string
go.mod
View file @
102348d1
...
...
@@ -13,6 +13,7 @@ require (
cloud.google.com/go/compute/metadata v0.6.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/blues/jsonata-go v1.5.4 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
...
...
@@ -24,6 +25,10 @@ require (
github.com/getsentry/sentry-go v0.12.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/goccy/go-yaml v1.17.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
...
...
@@ -37,6 +42,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
...
...
@@ -60,6 +66,9 @@ require (
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/std-uritemplate/std-uritemplate/go/v2 v2.0.3 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/http-swagger v1.3.4 // indirect
github.com/swaggo/swag v1.16.4 // indirect
github.com/test-go/testify v1.1.4 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
...
...
@@ -74,13 +83,14 @@ require (
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
golang.org/x/crypto v0.3
7
.0 // indirect
golang.org/x/crypto v0.3
8
.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/net v0.
39
.0 // indirect
golang.org/x/sync v0.1
3
.0 // indirect
golang.org/x/sys v0.3
2
.0 // indirect
golang.org/x/text v0.2
4
.0 // indirect
golang.org/x/net v0.
40
.0 // indirect
golang.org/x/sync v0.1
4
.0 // indirect
golang.org/x/sys v0.3
3
.0 // indirect
golang.org/x/text v0.2
5
.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.33.0 // indirect
google.golang.org/genai v1.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
google.golang.org/grpc v1.72.0 // indirect
...
...
go.sum
View file @
102348d1
This diff is collapsed.
Click to expand it.
main.go
View file @
102348d1
...
...
@@ -11,6 +11,9 @@ import (
"github.com/wade-liwei/agentchat/plugins/deepseek"
"github.com/firebase/genkit/go/plugins/server"
httpSwagger
"github.com/swaggo/http-swagger"
_
"github.com/wade-liwei/agentchat/docs"
// 导入生成的 Swagger 文档
)
...
...
@@ -77,6 +80,22 @@ func main() {
mux
.
Handle
(
"POST /"
+
a
.
Name
(),
handler
)
}
//mux.HandleFunc("/swagger/", httpSwagger.WrapHandler)
// 暴露 Swagger UI,使用 swagger.yaml
// mux.HandleFunc("/swagger/", httpSwagger.Handler(
// httpSwagger.URL("/swagger/doc.yaml"), // 指定 YAML 文件路径
// ))
// 暴露 Swagger UI,使用 swagger.yaml
mux
.
HandleFunc
(
"/swagger/"
,
httpSwagger
.
Handler
(
httpSwagger
.
URL
(
"/docs/swagger.yaml"
),
// 指定 YAML 文件路径
))
// 确保 docs 目录可通过 HTTP 访问
mux
.
Handle
(
"/docs/"
,
http
.
StripPrefix
(
"/docs/"
,
http
.
FileServer
(
http
.
Dir
(
"docs"
))))
// 启动服务器,监听
log
.
Printf
(
"Server starting on 0.0.0.0:8000"
)
if
err
:=
server
.
Start
(
ctx
,
"0.0.0.0:8000"
,
mux
);
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment