Skip to content

Commit

Permalink
Created swagger in project for API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
burkaydurdu committed Mar 5, 2022
1 parent 601c493 commit 680d02a
Show file tree
Hide file tree
Showing 8 changed files with 705 additions and 25 deletions.
287 changes: 287 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
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.shortly.io/support",
"email": "support@shortly.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/create": {
"post": {
"description": "It gives short URL",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Create Short URL"
],
"summary": "Generate short URL",
"parameters": [
{
"description": "Original URL is required",
"name": "original_url",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/shortly.SaveRequestDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/shortly.SaveResponseDTO"
}
},
"400": {
"description": "Request body is not valid",
"schema": {
"$ref": "#/definitions/shortly.ErrResponseDTO"
}
},
"409": {
"description": "URL is not valid",
"schema": {
"$ref": "#/definitions/shortly.ErrResponseDTO"
}
}
}
}
},
"/api/v1/health": {
"get": {
"description": "It helps server tracking",
"produces": [
"text/plain"
],
"tags": [
"Health"
],
"summary": "Server Health",
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/list": {
"get": {
"description": "It gives all shortly data",
"tags": [
"All Shortly List"
],
"summary": "Get All Shortly List",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/db.Shortly"
}
}
}
}
}
},
"/{code}": {
"get": {
"description": "It redirects from short URL to original URL",
"tags": [
"Redirect"
],
"summary": "Short URL",
"parameters": [
{
"type": "string",
"description": "Shortly Code",
"name": "code",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": "Not found",
"schema": {
"type": "string"
}
}
}
},
"put": {
"description": "It redirects from short URL to original URL",
"tags": [
"Redirect"
],
"summary": "Short URL",
"parameters": [
{
"type": "string",
"description": "Shortly Code",
"name": "code",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": "Not found",
"schema": {
"type": "string"
}
}
}
},
"post": {
"description": "It redirects from short URL to original URL",
"tags": [
"Redirect"
],
"summary": "Short URL",
"parameters": [
{
"type": "string",
"description": "Shortly Code",
"name": "code",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": "Not found",
"schema": {
"type": "string"
}
}
}
},
"delete": {
"description": "It redirects from short URL to original URL",
"tags": [
"Redirect"
],
"summary": "Short URL",
"parameters": [
{
"type": "string",
"description": "Shortly Code",
"name": "code",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": ""
},
"404": {
"description": "Not found",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
"db.Shortly": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"original_url": {
"type": "string"
},
"short_url": {
"type": "string"
},
"visit_count": {
"type": "integer"
}
}
},
"shortly.ErrResponseDTO": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"shortly.SaveRequestDTO": {
"type": "object",
"properties": {
"original_url": {
"type": "string"
}
}
},
"shortly.SaveResponseDTO": {
"type": "object",
"properties": {
"short_url": {
"type": "string"
}
}
}
}
}`

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

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
Loading

0 comments on commit 680d02a

Please sign in to comment.