Skip to content

Commit

Permalink
shortlink-api: add generate swagger of docs
Browse files Browse the repository at this point in the history
Signed-off-by: Login Victor <batazor@evrone.com>
  • Loading branch information
batazor committed Aug 21, 2022
1 parent 773fd21 commit 17a0fb4
Show file tree
Hide file tree
Showing 11 changed files with 508 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ help: ## Display this help screen
# INCLUDE ==============================================================================================================
# Include Makefile
include $(SELF_DIR)/ops/Makefile/common.mk
include $(SELF_DIR)/ops/Makefile/docs.mk
include $(SELF_DIR)/ops/Makefile/cert.mk
include $(SELF_DIR)/ops/Makefile/proto.mk
include $(SELF_DIR)/ops/Makefile/cli.mk
Expand Down
170 changes: 170 additions & 0 deletions docs/api/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Package api GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
package api

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": "Shortlink repository",
"url": "https://github.com/batazor/shortlink/issues",
"email": "support@swagger.io"
},
"license": {
"name": "MIT",
"url": "http://www.opensource.org/licenses/MIT"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/links": {
"get": {
"description": "List links",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "List links",
"operationId": "list-links",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.ListResponse"
}
}
}
}
},
"/links/{hash}": {
"get": {
"description": "Get link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get link",
"operationId": "get-link",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetResponse"
}
}
}
},
"delete": {
"description": "Delete link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Delete link",
"operationId": "delete-link",
"responses": {
"200": {
"description": ""
}
}
}
}
},
"definitions": {
"timestamppb.Timestamp": {
"type": "object",
"properties": {
"nanos": {
"description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive.",
"type": "integer"
},
"seconds": {
"description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.",
"type": "integer"
}
}
},
"v1.GetResponse": {
"type": "object",
"properties": {
"link": {
"$ref": "#/definitions/v1.Link"
}
}
},
"v1.Link": {
"type": "object",
"properties": {
"created_at": {
"description": "Create at",
"$ref": "#/definitions/timestamppb.Timestamp"
},
"describe": {
"description": "Describe of link",
"type": "string"
},
"hash": {
"description": "Hash by URL + salt",
"type": "string"
},
"updated_at": {
"description": "Update at",
"$ref": "#/definitions/timestamppb.Timestamp"
},
"url": {
"description": "URL",
"type": "string"
}
}
},
"v1.Links": {
"type": "object",
"properties": {
"link": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.Link"
}
}
}
},
"v1.ListResponse": {
"type": "object",
"properties": {
"links": {
"$ref": "#/definitions/v1.Links"
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:7070",
BasePath: "/api",
Schemes: []string{},
Title: "Shortlink API",
Description: "Shortlink API",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
147 changes: 147 additions & 0 deletions docs/api/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"swagger": "2.0",
"info": {
"description": "Shortlink API",
"title": "Shortlink API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Shortlink repository",
"url": "https://github.com/batazor/shortlink/issues",
"email": "support@swagger.io"
},
"license": {
"name": "MIT",
"url": "http://www.opensource.org/licenses/MIT"
},
"version": "1.0"
},
"host": "localhost:7070",
"basePath": "/api",
"paths": {
"/links": {
"get": {
"description": "List links",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "List links",
"operationId": "list-links",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.ListResponse"
}
}
}
}
},
"/links/{hash}": {
"get": {
"description": "Get link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get link",
"operationId": "get-link",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetResponse"
}
}
}
},
"delete": {
"description": "Delete link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Delete link",
"operationId": "delete-link",
"responses": {
"200": {
"description": ""
}
}
}
}
},
"definitions": {
"timestamppb.Timestamp": {
"type": "object",
"properties": {
"nanos": {
"description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive.",
"type": "integer"
},
"seconds": {
"description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.",
"type": "integer"
}
}
},
"v1.GetResponse": {
"type": "object",
"properties": {
"link": {
"$ref": "#/definitions/v1.Link"
}
}
},
"v1.Link": {
"type": "object",
"properties": {
"created_at": {
"description": "Create at",
"$ref": "#/definitions/timestamppb.Timestamp"
},
"describe": {
"description": "Describe of link",
"type": "string"
},
"hash": {
"description": "Hash by URL + salt",
"type": "string"
},
"updated_at": {
"description": "Update at",
"$ref": "#/definitions/timestamppb.Timestamp"
},
"url": {
"description": "URL",
"type": "string"
}
}
},
"v1.Links": {
"type": "object",
"properties": {
"link": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.Link"
}
}
}
},
"v1.ListResponse": {
"type": "object",
"properties": {
"links": {
"$ref": "#/definitions/v1.Links"
}
}
}
}
}

0 comments on commit 17a0fb4

Please sign in to comment.