Skip to content

Commit

Permalink
regenerate swagger doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Sep 23, 2023
1 parent fcefaba commit f0062fa
Show file tree
Hide file tree
Showing 10 changed files with 1,178 additions and 27 deletions.
19 changes: 19 additions & 0 deletions api/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package api

import (
"embed"
"io/fs"
"net/http"
)

//go:embed doc.swagger.json
var doc embed.FS

func OpenAPIHandler() http.Handler {
// Use subdirectory in embedded files
subFS, err := fs.Sub(doc, ".")
if err != nil {
panic("couldn't create sub filesystem: " + err.Error())
}
return http.FileServer(http.FS(subFS))
}
201 changes: 201 additions & 0 deletions api/doc.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"swagger": "2.0",
"info": {
"title": "helloworld demo api definition",
"version": "1.0",
"contact": {
"name": "douyu",
"url": "https://github.com/douyu/proto"
}
},
"tags": [
{
"name": "helloworld.v1.GreeterService"
},
{
"name": "Project 001",
"description": "This is how we do it.",
"externalDocs": {
"description": "Find out more",
"url": "https://github.com/douyu/proto"
}
}
],
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"paths": {
"/v1/helloworld.Greeter/SayHello": {
"post": {
"summary": "Sends a hello greeting",
"operationId": "GreeterService_SayHello",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1SayHelloResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "The request message containing the user's name.",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1SayHelloRequest"
}
},
{
"name": "token",
"description": "Token Header",
"in": "header",
"required": true,
"type": "string"
}
],
"tags": [
"Project 001"
]
}
},
"/v1/helloworld.Greeter/SayHello/{name}": {
"get": {
"summary": "Sends a hello greeting",
"operationId": "GreeterService_SayHello2",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1SayHelloResponse"
}
}
},
"parameters": [
{
"name": "name",
"description": "name ...",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "token",
"description": "Token Header",
"in": "header",
"required": true,
"type": "string"
}
],
"tags": [
"Project 001"
]
}
}
},
"definitions": {
"v1SayHelloRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "name ..."
}
},
"description": "The request message containing the user's name."
},
"v1SayHelloResponse": {
"type": "object",
"properties": {
"error": {
"type": "integer",
"format": "int64",
"title": "error"
},
"msg": {
"type": "string",
"title": "msg"
},
"data": {
"$ref": "#/definitions/v1SayHelloResponseData",
"description": "data ..."
}
},
"title": "The response message containing the greetings"
},
"v1SayHelloResponseData": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "name of the user"
},
"ageNumber": {
"type": "string",
"format": "uint64",
"description": "age_number is the age number."
},
"sex": {
"$ref": "#/definitions/v1Sex",
"title": "sex is the user's sex"
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"title": "metadata is the user's metadata"
}
},
"description": "Data is the data to be sent."
},
"v1SayHiResponse": {
"type": "object",
"properties": {
"error": {
"type": "integer",
"format": "int64",
"title": "error"
},
"msg": {
"type": "string",
"title": "msg"
},
"data": {
"$ref": "#/definitions/v1SayHiResponseData",
"description": "data ..."
}
},
"title": "The response message containing the greetings"
},
"v1SayHiResponseData": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "name of the user"
},
"ageNumber": {
"type": "string",
"format": "uint64",
"description": "age_number is the age number."
}
},
"description": "Data is the data to be sent."
},
"v1Sex": {
"type": "integer",
"format": "int32",
"enum": [
1,
2
],
"description": "- 1: SEX_MALE ...\n - 2: SEX_FEMALE ...",
"title": "Sex"
}
}
}
96 changes: 96 additions & 0 deletions api/error/v1/error.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f0062fa

Please sign in to comment.