forked from swaggo/gin-swagger
-
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.
- Loading branch information
1 parent
dce16ba
commit 1e97bf3
Showing
19 changed files
with
882 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out |
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,13 @@ | ||
language: go | ||
|
||
go: | ||
- 1.8.x | ||
|
||
before_install: | ||
- go get -t -v ./... | ||
|
||
script: | ||
- go test -coverprofile=coverage.txt -covermode=atomic | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
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,40 @@ | ||
package api | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gin-gonic/gin" | ||
"github.com/swag-gonic/swag/example/web" | ||
) | ||
|
||
// | ||
// @Summary Add a new pet to the store | ||
// @Description get string by ID | ||
// @Accept json | ||
// @Produce json | ||
// @Param some_id path int true "Some ID" | ||
// @Success 200 {string} string "ok" | ||
// @Failure 400 {object} web.APIError "We need ID!!" | ||
// @Failure 404 {object} web.APIError "Can not find ID" | ||
// @Router /testapi/get-string-by-int/{some_id} [get] | ||
func GetStringByInt(c *gin.Context) { | ||
err := web.APIError{} | ||
fmt.Println(err) | ||
} | ||
|
||
// @Description get struct array by ID | ||
// @Accept json | ||
// @Produce json | ||
// @Param some_id path string true "Some ID" | ||
// @Param offset query int true "Offset" | ||
// @Param limit query int true "Offset" | ||
// @Success 200 {string} string "ok" | ||
// @Failure 400 {object} web.APIError "We need ID!!" | ||
// @Failure 404 {object} web.APIError "Can not find ID" | ||
// @Router /testapi/get-struct-array-by-string/{some_id} [get] | ||
func GetStructArrayByString(c *gin.Context) { | ||
|
||
} | ||
|
||
type Pet3 struct { | ||
ID int `json:"id"` | ||
} |
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,161 @@ | ||
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT | ||
// This file was generated by swag-gonic/swag at | ||
// 2017-06-25 01:25:37.872454531 +0800 CST | ||
|
||
package docs | ||
|
||
import ( | ||
"github.com/swag-gonic/swag/swagger" | ||
) | ||
|
||
var doc = `{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This is a sample server Petstore server.", | ||
"title": "Swagger Example 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": "petstore.swagger.io", | ||
"basePath": "/v2", | ||
"paths": { | ||
"/testapi/get-string-by-int/{some_id}": { | ||
"get": { | ||
"description": "get string by ID", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Add a new pet to the store", | ||
"parameters": [ | ||
{ | ||
"description": "Some ID", | ||
"name": "some_id", | ||
"in": "path", | ||
"required": true, | ||
"schema": { | ||
"type": "int" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "ok", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
"400": { | ||
"description": "We need ID!!", | ||
"schema": { | ||
"type": "object", | ||
"$ref": "#/definitions/web.APIError" | ||
} | ||
}, | ||
"404": { | ||
"description": "Can not find ID", | ||
"schema": { | ||
"type": "object", | ||
"$ref": "#/definitions/web.APIError" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/testapi/get-struct-array-by-string/{some_id}": { | ||
"get": { | ||
"description": "get struct array by ID", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"parameters": [ | ||
{ | ||
"description": "Some ID", | ||
"name": "some_id", | ||
"in": "path", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Offset", | ||
"name": "offset", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "int" | ||
} | ||
}, | ||
{ | ||
"description": "Offset", | ||
"name": "limit", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "int" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "ok", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
"400": { | ||
"description": "We need ID!!", | ||
"schema": { | ||
"type": "object", | ||
"$ref": "#/definitions/web.APIError" | ||
} | ||
}, | ||
"404": { | ||
"description": "Can not find ID", | ||
"schema": { | ||
"type": "object", | ||
"$ref": "#/definitions/web.APIError" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"web.APIError": { | ||
"type": "object", | ||
"properties": { | ||
"ErrorCode": { | ||
"type": "int" | ||
}, | ||
"ErrorMessage": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
type s struct{} | ||
|
||
func (s *s) ReadDoc() string { | ||
return doc | ||
} | ||
func init() { | ||
swagger.Register(swagger.Name, &s{}) | ||
} |
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,31 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/swag-gonic/gin-swagger" | ||
"github.com/swag-gonic/gin-swagger/swaggerFiles" | ||
|
||
_ "github.com/swag-gonic/gin-swagger/example/docs" | ||
) | ||
|
||
// @title Swagger Example API | ||
// @version 1.0 | ||
// @description This is a sample server Petstore server. | ||
// @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 petstore.swagger.io | ||
// @BasePath /v2 | ||
func main() { | ||
r := gin.New() | ||
|
||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) | ||
|
||
r.Run() | ||
} |
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,27 @@ | ||
package web | ||
|
||
// @hello | ||
// yo yo yo yo | ||
type Pet struct { | ||
ID int `json:"id"` | ||
Category struct { | ||
ID int `json:"id"` | ||
Name string `json:"name"` | ||
} `json:"category"` | ||
Name string `json:"name"` | ||
PhotoUrls []string `json:"photoUrls"` | ||
Tags []struct { | ||
ID int `json:"id"` | ||
Name string `json:"name"` | ||
} `json:"tags"` | ||
Status string `json:"status"` | ||
} | ||
|
||
type Pet2 struct { | ||
ID int `json:"id"` | ||
} | ||
|
||
type APIError struct { | ||
ErrorCode int | ||
ErrorMessage string | ||
} |
Oops, something went wrong.