Skip to content

Commit e5ac771

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add-oauth-config
2 parents 57d78e6 + 80f04ba commit e5ac771

11 files changed

Lines changed: 740 additions & 451 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
go: [ '1.15.x', '1.16.x', '1.17.x', '1.18.x' ]
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@master
17+
- name: Set up Go
18+
uses: actions/setup-go@v1
19+
with:
20+
go-version: ${{ matrix.go }}
21+
- name: test
22+
run: go test -coverprofile=coverage.txt -covermode=atomic
23+
- name: coverage
24+
run: bash <(curl -s https://codecov.io/bash)

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.dll
4+
*.so
5+
*.dylib
6+
7+
# Test binary, build with `go test -c`
8+
*.test
9+
10+
# Output of the go coverage tool, specifically when used with LiteIDE
11+
*.out
12+
dist
13+
14+
.idea
15+
vendor
16+
.envrc
17+

.goreleaser.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
builds:
2+
- skip: true
3+
snapshot:
4+
name_template: "{{ .Tag }}-next"
5+
changelog:
6+
sort: asc
7+
filters:
8+
exclude:
9+
- '^docs:'
10+
- '^test:'

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**Describe the PR**
2+
e.g. add cool parser.
3+
4+
**Relation issue**
5+
e.g. https://github.com/swaggo/gin-swagger/pull/123/files
6+
7+
**Additional context**
8+
Add any other context about the problem here.

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
echo middleware to automatically generate RESTful API documentation with Swagger 2.0.
44

5-
[![Travis branch](https://img.shields.io/travis/swaggo/echo-swagger/master.svg)](https://travis-ci.org/swaggo/echo-swagger)
5+
[![Build Status](https://github.com/swaggo/echo-swagger/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/features/actions)
66
[![Codecov branch](https://img.shields.io/codecov/c/github/swaggo/echo-swagger/master.svg)](https://codecov.io/gh/swaggo/echo-swagger)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/swaggo/echo-swagger)](https://goreportcard.com/report/github.com/swaggo/echo-swagger)
8+
[![Release](https://img.shields.io/github/release/swaggo/echo-swagger.svg?style=flat-square)](https://github.com/swaggo/echo-swagger/releases)
89

910

1011
## Usage
@@ -13,7 +14,10 @@ echo middleware to automatically generate RESTful API documentation with Swagger
1314
1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag#declarative-comments-format).
1415
2. Download [Swag](https://github.com/swaggo/swag) for Go by using:
1516
```sh
16-
$ go get github.com/swaggo/swag/cmd/swag
17+
$ go get -d github.com/swaggo/swag/cmd/swag
18+
19+
# 1.16 or newer
20+
$ go install github.com/swaggo/swag/cmd/swag@latest
1721
```
1822
3. Run the [Swag](https://github.com/swaggo/swag) in your Go project root folder which contains `main.go` file, [Swag](https://github.com/swaggo/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`).
1923
```sh_ "github.com/swaggo/echo-swagger/v2/example/docs"
@@ -69,3 +73,17 @@ func main() {
6973

7074
![swagger_index.html](https://user-images.githubusercontent.com/8943871/36250587-40834072-1279-11e8-8bb7-02a2e2fdd7a7.png)
7175

76+
Note: If you are using Gzip middleware you should add the swagger endpoint to skipper
77+
78+
### Example
79+
80+
```
81+
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
82+
Skipper: func(c echo.Context) bool {
83+
if strings.Contains(c.Request().URL.Path, "swagger") {
84+
return true
85+
}
86+
return false
87+
},
88+
}))
89+
```

example/docs/docs.go

Lines changed: 23 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
2-
// This file was generated by swaggo/swag at
3-
// 2018-01-12 18:44:40.928256 +0800 CST m=+0.272034118
4-
1+
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
2+
// This file was generated by swaggo/swag
53
package docs
64

7-
import (
8-
"github.com/swaggo/swag"
9-
)
5+
import "github.com/swaggo/swag"
106

11-
var doc = `{
7+
const docTemplate_swagger = `{
8+
"schemes": {{ marshal .Schemes }},
129
"swagger": "2.0",
1310
"info": {
14-
"description": "This is a sample server Petstore server.",
15-
"title": "Swagger Example API",
11+
"description": "{{escape .Description}}",
12+
"title": "{{.Title}}",
1613
"termsOfService": "http://swagger.io/terms/",
1714
"contact": {
1815
"name": "API Support",
@@ -23,214 +20,25 @@ var doc = `{
2320
"name": "Apache 2.0",
2421
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
2522
},
26-
"version": "1.0"
27-
},
28-
"host": "petstore.swagger.io",
29-
"basePath": "/v2",
30-
"paths": {
31-
"/file/upload": {
32-
"post": {
33-
"description": "Upload file",
34-
"consumes": [
35-
"multipart/form-data"
36-
],
37-
"produces": [
38-
"application/json"
39-
],
40-
"summary": "Upload file",
41-
"operationId": "file.upload",
42-
"parameters": [
43-
{
44-
"type": "file",
45-
"description": "this is a test file",
46-
"name": "file",
47-
"in": "formData",
48-
"required": true
49-
}
50-
],
51-
"responses": {
52-
"200": {
53-
"description": "ok",
54-
"schema": {
55-
"type": "string"
56-
}
57-
},
58-
"400": {
59-
"description": "We need ID!!",
60-
"schema": {
61-
"type": "object",
62-
"$ref": "#/definitions/web.APIError"
63-
}
64-
},
65-
"404": {
66-
"description": "Can not find ID",
67-
"schema": {
68-
"type": "object",
69-
"$ref": "#/definitions/web.APIError"
70-
}
71-
}
72-
}
73-
}
74-
},
75-
"/testapi/get-string-by-int/{some_id}": {
76-
"get": {
77-
"description": "get string by ID",
78-
"consumes": [
79-
"application/json"
80-
],
81-
"produces": [
82-
"application/json"
83-
],
84-
"summary": "Add a new pet to the store",
85-
"operationId": "get-string-by-int",
86-
"parameters": [
87-
{
88-
"type": "int",
89-
"description": "Some ID",
90-
"name": "some_id",
91-
"in": "path",
92-
"required": true
93-
},
94-
{
95-
"description": "Some ID",
96-
"name": "some_id",
97-
"in": "body",
98-
"required": true,
99-
"schema": {
100-
"type": "object",
101-
"$ref": "#/definitions/web.Pet"
102-
}
103-
}
104-
],
105-
"responses": {
106-
"200": {
107-
"description": "ok",
108-
"schema": {
109-
"type": "string"
110-
}
111-
},
112-
"400": {
113-
"description": "We need ID!!",
114-
"schema": {
115-
"type": "object",
116-
"$ref": "#/definitions/web.APIError"
117-
}
118-
},
119-
"404": {
120-
"description": "Can not find ID",
121-
"schema": {
122-
"type": "object",
123-
"$ref": "#/definitions/web.APIError"
124-
}
125-
}
126-
}
127-
}
128-
},
129-
"/testapi/get-struct-array-by-string/{some_id}": {
130-
"get": {
131-
"description": "get struct array by ID",
132-
"consumes": [
133-
"application/json"
134-
],
135-
"produces": [
136-
"application/json"
137-
],
138-
"operationId": "get-struct-array-by-string",
139-
"parameters": [
140-
{
141-
"type": "string",
142-
"description": "Some ID",
143-
"name": "some_id",
144-
"in": "path",
145-
"required": true
146-
},
147-
{
148-
"type": "int",
149-
"description": "Offset",
150-
"name": "offset",
151-
"in": "query",
152-
"required": true
153-
},
154-
{
155-
"type": "int",
156-
"description": "Offset",
157-
"name": "limit",
158-
"in": "query",
159-
"required": true
160-
}
161-
],
162-
"responses": {
163-
"200": {
164-
"description": "ok",
165-
"schema": {
166-
"type": "string"
167-
}
168-
},
169-
"400": {
170-
"description": "We need ID!!",
171-
"schema": {
172-
"type": "object",
173-
"$ref": "#/definitions/web.APIError"
174-
}
175-
},
176-
"404": {
177-
"description": "Can not find ID",
178-
"schema": {
179-
"type": "object",
180-
"$ref": "#/definitions/web.APIError"
181-
}
182-
}
183-
}
184-
}
185-
}
23+
"version": "{{.Version}}"
18624
},
187-
"definitions": {
188-
"web.APIError": {
189-
"type": "object",
190-
"properties": {
191-
"CreatedAt": {
192-
"type": "string",
193-
"format": "date-time"
194-
},
195-
"ErrorCode": {
196-
"type": "integer"
197-
},
198-
"ErrorMessage": {
199-
"type": "string"
200-
}
201-
}
202-
},
203-
"web.Pet": {
204-
"type": "object",
205-
"properties": {
206-
"Category": {
207-
"type": "object"
208-
},
209-
"ID": {
210-
"type": "integer"
211-
},
212-
"Name": {
213-
"type": "string"
214-
},
215-
"PhotoUrls": {
216-
"type": "array"
217-
},
218-
"Status": {
219-
"type": "string"
220-
},
221-
"Tags": {
222-
"type": "array"
223-
}
224-
}
225-
}
226-
}
25+
"host": "{{.Host}}",
26+
"basePath": "{{.BasePath}}",
27+
"paths": {}
22728
}`
22829

229-
type s struct{}
230-
231-
func (s *s) ReadDoc() string {
232-
return doc
30+
// SwaggerInfo_swagger holds exported Swagger Info so clients can modify it
31+
var SwaggerInfo_swagger = &swag.Spec{
32+
Version: "1.0",
33+
Host: "petstore.swagger.io",
34+
BasePath: "/v2",
35+
Schemes: []string{},
36+
Title: "Swagger Example API",
37+
Description: "This is a sample server Petstore server.",
38+
InfoInstanceName: "swagger",
39+
SwaggerTemplate: docTemplate_swagger,
23340
}
41+
23442
func init() {
235-
swag.Register(swag.Name, &s{})
43+
swag.Register(SwaggerInfo_swagger.InstanceName(), SwaggerInfo_swagger)
23644
}

0 commit comments

Comments
 (0)