Skip to content

Commit

Permalink
add swagger
Browse files Browse the repository at this point in the history
Signed-off-by: Jirka Kremser <[email protected]>
  • Loading branch information
jkremser committed Nov 19, 2024
1 parent 0a5711b commit 870ee88
Show file tree
Hide file tree
Showing 6 changed files with 496 additions and 17 deletions.
154 changes: 154 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// 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": {
"/info": {
"get": {
"description": "this will return versions, ports, ...",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"info"
],
"summary": "get basic info about the app",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/memstore/data": {
"get": {
"description": "this will return detailed metrics, including all the datapoints and calculated aggregates",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"metrics"
],
"summary": "get metrics dump",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/rest.MetricDataPayload"
}
}
}
}
}
}
},
"/memstore/names": {
"get": {
"description": "this will return the metric names of all tracked metric series in the store",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"metrics"
],
"summary": "get metric names in the store",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"rest.MetricDataPayload": {
"type": "object",
"properties": {
"aggregatesOverTime": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/types.ObservedValue"
}
},
"labels": {
"$ref": "#/definitions/types.Labels"
},
"lastUpdate": {
"type": "integer"
}
}
},
"types.Labels": {
"type": "object",
"additionalProperties": {}
},
"types.ObservedValue": {
"type": "object",
"properties": {
"time": {
"description": "timestamp of last update (in seconds)",
"type": "integer"
},
"value": {
"description": "observed value",
"type": "number"
}
}
}
}
}`

// 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)
}
125 changes: 125 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"swagger": "2.0",
"info": {
"contact": {}
},
"paths": {
"/info": {
"get": {
"description": "this will return versions, ports, ...",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"info"
],
"summary": "get basic info about the app",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/memstore/data": {
"get": {
"description": "this will return detailed metrics, including all the datapoints and calculated aggregates",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"metrics"
],
"summary": "get metrics dump",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/rest.MetricDataPayload"
}
}
}
}
}
}
},
"/memstore/names": {
"get": {
"description": "this will return the metric names of all tracked metric series in the store",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"metrics"
],
"summary": "get metric names in the store",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"rest.MetricDataPayload": {
"type": "object",
"properties": {
"aggregatesOverTime": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/types.ObservedValue"
}
},
"labels": {
"$ref": "#/definitions/types.Labels"
},
"lastUpdate": {
"type": "integer"
}
}
},
"types.Labels": {
"type": "object",
"additionalProperties": {}
},
"types.ObservedValue": {
"type": "object",
"properties": {
"time": {
"description": "timestamp of last update (in seconds)",
"type": "integer"
},
"value": {
"description": "observed value",
"type": "number"
}
}
}
}
}
83 changes: 83 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
definitions:
rest.MetricDataPayload:
properties:
aggregatesOverTime:
additionalProperties:
type: number
type: object
data:
items:
$ref: '#/definitions/types.ObservedValue'
type: array
labels:
$ref: '#/definitions/types.Labels'
lastUpdate:
type: integer
type: object
types.Labels:
additionalProperties: {}
type: object
types.ObservedValue:
properties:
time:
description: timestamp of last update (in seconds)
type: integer
value:
description: observed value
type: number
type: object
info:
contact: {}
paths:
/info:
get:
consumes:
- application/json
description: this will return versions, ports, ...
produces:
- application/json
responses:
"200":
description: OK
summary: get basic info about the app
tags:
- info
/memstore/data:
get:
consumes:
- application/json
description: this will return detailed metrics, including all the datapoints
and calculated aggregates
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties:
items:
$ref: '#/definitions/rest.MetricDataPayload'
type: array
type: object
summary: get metrics dump
tags:
- metrics
/memstore/names:
get:
consumes:
- application/json
description: this will return the metric names of all tracked metric series
in the store
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
type: string
type: array
summary: get metric names in the store
tags:
- metrics
swagger: "2.0"
Loading

0 comments on commit 870ee88

Please sign in to comment.