-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(doc): add initial swagger setup
- Loading branch information
Showing
7 changed files
with
199 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// 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": {}, | ||
"securityDefinitions": { | ||
"BasicAuth": { | ||
"type": "basic" | ||
} | ||
}, | ||
"externalDocs": { | ||
"description": "OpenAPI", | ||
"url": "https://swagger.io/resources/open-api/" | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0", | ||
Host: "localhost:8080", | ||
BasePath: "/api/v1", | ||
Schemes: []string{}, | ||
Title: "Short Spot API", | ||
Description: "Short Spot API is a simple URL shortener service", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "Short Spot API is a simple URL shortener service", | ||
"title": "Short Spot 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": "localhost:8080", | ||
"basePath": "/api/v1", | ||
"paths": {}, | ||
"securityDefinitions": { | ||
"BasicAuth": { | ||
"type": "basic" | ||
} | ||
}, | ||
"externalDocs": { | ||
"description": "OpenAPI", | ||
"url": "https://swagger.io/resources/open-api/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
basePath: /api/v1 | ||
externalDocs: | ||
description: OpenAPI | ||
url: https://swagger.io/resources/open-api/ | ||
host: localhost:8080 | ||
info: | ||
contact: | ||
email: [email protected] | ||
name: API Support | ||
url: http://www.swagger.io/support | ||
description: Short Spot API is a simple URL shortener service | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
termsOfService: http://swagger.io/terms/ | ||
title: Short Spot API | ||
version: "1.0" | ||
paths: {} | ||
securityDefinitions: | ||
BasicAuth: | ||
type: basic | ||
swagger: "2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,33 @@ import ( | |
"os/signal" | ||
|
||
"github.com/vit0rr/short-spot/api/server" | ||
_ "github.com/vit0rr/short-spot/cmd/api/docs" | ||
"github.com/vit0rr/short-spot/config" | ||
"github.com/vit0rr/short-spot/pkg/deps" | ||
"github.com/vit0rr/short-spot/pkg/log" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
"go.mongodb.org/mongo-driver/mongo/options" | ||
) | ||
|
||
// @title Short Spot API | ||
// @version 1.0 | ||
// @description Short Spot API is a simple URL shortener service | ||
// @termsOfService http://swagger.io/terms/ | ||
|
||
// @contact.name API Support | ||
// @contact.url http://www.swagger.io/support | ||
// @contact.email [email protected] | ||
|
||
// @license.name Apache 2.0 | ||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html | ||
|
||
// @host localhost:8080 | ||
// @BasePath /api/v1 | ||
|
||
// @securityDefinitions.basic BasicAuth | ||
|
||
// @externalDocs.description OpenAPI | ||
// @externalDocs.url https://swagger.io/resources/open-api/ | ||
func main() { | ||
ctx := context.Background() | ||
// Parse config file location from command-line flag | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters