Skip to content

Commit

Permalink
feat(api): Add swagger page
Browse files Browse the repository at this point in the history
  • Loading branch information
Randsw committed Nov 29, 2023
1 parent c83ff19 commit e7b36ca
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 0 deletions.
82 changes: 82 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// 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}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/GetNodes": {
"get": {
"produces": [
"application/json"
],
"summary": "Get info about nodes in cluster",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/kubeApiResponseStruct.NodeRespose"
}
}
}
}
}
},
"definitions": {
"kubeApiResponseStruct.NodeRespose": {
"type": "object",
"properties": {
"contolplanenumber": {
"type": "integer"
},
"kubernetesversion": {
"type": "string"
},
"nodenumber": {
"type": "integer"
},
"osimage": {
"type": "string"
},
"workernumber": {
"type": "integer"
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "kubeinfo.swagger.io",
BasePath: "/",
Schemes: []string{},
Title: "Kubeinfo API",
Description: "Kubeinfo used to get information about k8s cluster component",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
60 changes: 60 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"swagger": "2.0",
"info": {
"description": "Kubeinfo used to get information about k8s cluster component",
"title": "Kubeinfo API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0"
},
"host": "kubeinfo.swagger.io",
"basePath": "/",
"paths": {
"/GetNodes": {
"get": {
"produces": [
"application/json"
],
"summary": "Get info about nodes in cluster",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/kubeApiResponseStruct.NodeRespose"
}
}
}
}
}
},
"definitions": {
"kubeApiResponseStruct.NodeRespose": {
"type": "object",
"properties": {
"contolplanenumber": {
"type": "integer"
},
"kubernetesversion": {
"type": "string"
},
"nodenumber": {
"type": "integer"
},
"osimage": {
"type": "string"
},
"workernumber": {
"type": "integer"
}
}
}
}
}
40 changes: 40 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
basePath: /
definitions:
kubeApiResponseStruct.NodeRespose:
properties:
contolplanenumber:
type: integer
kubernetesversion:
type: string
nodenumber:
type: integer
osimage:
type: string
workernumber:
type: integer
type: object
host: kubeinfo.swagger.io
info:
contact:
email: [email protected]
name: API Support
url: http://www.swagger.io/support
description: Kubeinfo used to get information about k8s cluster component
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Kubeinfo API
version: "1.0"
paths:
/GetNodes:
get:
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/kubeApiResponseStruct.NodeRespose'
summary: Get info about nodes in cluster
swagger: "2.0"
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ require (
github.com/gorilla/mux v1.8.1
github.com/prometheus/client_golang v1.17.0
github.com/randsw/cascadescenariocontroller v0.0.0-20220708134100-ae9c30dea846
github.com/swaggo/http-swagger/example/gorilla v0.0.0-20230830153024-537f045bded0
github.com/swaggo/http-swagger/v2 v2.0.2
go.uber.org/zap v1.26.0
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -25,6 +28,7 @@ require (
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand All @@ -45,13 +49,16 @@ require (
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag v1.8.1 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
Loading

0 comments on commit e7b36ca

Please sign in to comment.