Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ Besides that, `swag` also accepts aliases for some MIME Types as follows:
| png | image/png |
| jpeg | image/jpeg |
| gif | image/gif |
| event-stream | text/event-stream |



Expand Down Expand Up @@ -963,7 +964,7 @@ If the struct is defined in a dependency package, use `--parseDependency`.

If the struct is defined in your main project, use `--parseInternal`.

if you want to include both internal and from dependencies use both flags
if you want to include both internal and from dependencies use both flags
```
swag init --parseDependency --parseInternal
```
Expand Down
1 change: 1 addition & 0 deletions README_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ Além disso, `swag` também aceita pseudónimos para alguns tipos de MIME, como
| png | image/png |
| jpeg | image/jpeg |
| gif | image/gif |
| event-stream | text/event-stream |



Expand Down
5 changes: 3 additions & 2 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/swaggo/swag)](https://goreportcard.com/report/github.com/swaggo/swag)
[![codebeat badge](https://codebeat.co/badges/71e2f5e5-9e6b-405d-baf9-7cc8b5037330)](https://codebeat.co/projects/github-com-swaggo-swag-master)
[![Go Doc](https://godoc.org/github.com/swaggo/swagg?status.svg)](https://godoc.org/github.com/swaggo/swag)
[![Backers on Open Collective](https://opencollective.com/swag/backers/badge.svg)](#backers)
[![Backers on Open Collective](https://opencollective.com/swag/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/swag/sponsors/badge.svg)](#sponsors) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fswaggo%2Fswag.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fswaggo%2Fswag?ref=badge_shield)
[![Release](https://img.shields.io/github/release/swaggo/swag.svg?style=flat-square)](https://github.com/swaggo/swag/releases)

Expand Down Expand Up @@ -299,7 +299,7 @@ swag init

## 格式化说明

可以针对Swag的注释自动格式化,就像`go fmt`。
可以针对Swag的注释自动格式化,就像`go fmt`。
此处查看格式化结果 [here](https://github.com/swaggo/swag/tree/master/example/celler).

示例:
Expand Down Expand Up @@ -417,6 +417,7 @@ Example [celler/controller](https://github.com/swaggo/swag/tree/master/example/c
| png | image/png |
| jpeg | image/jpeg |
| gif | image/gif |
| event-stream | text/event-stream |

## 参数类型

Expand Down
1 change: 1 addition & 0 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var mimeTypeAliases = map[string]string{
"png": "image/png",
"jpeg": "image/jpeg",
"gif": "image/gif",
"event-stream": "text/event-stream",
}

var mimeTypePattern = regexp.MustCompile("^[^/]+/[^/]+$")
Expand Down
16 changes: 9 additions & 7 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,10 @@ func TestParser_ParseAcceptComment(t *testing.T) {
"image/gif",
"application/xhtml+xml",
"application/health+json",
"text/event-stream",
}

comment := `@Accept json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream,png,jpeg,gif,application/xhtml+xml,application/health+json`
comment := `@Accept json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream,png,jpeg,gif,application/xhtml+xml,application/health+json,event-stream`

parser := New()
assert.NoError(t, parseGeneralAPIInfo(parser, []string{comment}))
Expand Down Expand Up @@ -521,9 +522,10 @@ func TestParser_ParseProduceComment(t *testing.T) {
"image/gif",
"application/xhtml+xml",
"application/health+json",
"text/event-stream",
}

comment := `@Produce json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream,png,jpeg,gif,application/xhtml+xml,application/health+json`
comment := `@Produce json,xml,plain,html,mpfd,x-www-form-urlencoded,json-api,json-stream,octet-stream,png,jpeg,gif,application/xhtml+xml,application/health+json,event-stream`

parser := New()
assert.NoError(t, parseGeneralAPIInfo(parser, []string{comment}))
Expand Down Expand Up @@ -3400,14 +3402,14 @@ func TestParseFunctionScopedComplexStructDefinition(t *testing.T) {
src := `
package main

// @Param request body main.Fun.request true "query params"
// @Param request body main.Fun.request true "query params"
// @Success 200 {object} main.Fun.response
// @Router /test [post]
func Fun() {
type request struct {
Name string
}

type grandChild struct {
Name string
}
Expand Down Expand Up @@ -3544,16 +3546,16 @@ package main

type PublicChild struct {
Name string
}
}

// @Param request body main.Fun.request true "query params"
// @Param request body main.Fun.request true "query params"
// @Success 200 {object} main.Fun.response
// @Router /test [post]
func Fun() {
type request struct {
Name string
}

type grandChild struct {
Name string
}
Expand Down