Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge master to v2 #1903

Merged
merged 88 commits into from
Oct 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
3c5e486
Update README_zh-CN.md (#1545)
tzxdtc Apr 11, 2023
01d20cc
Add option to set template delimiters (#1499)
leosunmo Apr 17, 2023
c14cc8e
fix bug: enums of explicit type conversion (#1556)
sdghchj Apr 17, 2023
21d34e2
add retract to fix proxy cache caused by accidentally pushed tags (#1…
Nerzal Apr 19, 2023
5774b7b
docs: doc to pt Add option to set template delims. (#1563)
Paulo-Lopes-Estevao May 3, 2023
e749ad5
fix: lint error for generated docs.go (#1583)
lowang-bh May 10, 2023
ea35767
fix bug: enums of underscored number (#1581)
sdghchj May 12, 2023
e73a0d0
fix using tab (\t) as separator for custom type names (#1594)
nitram509 Jun 7, 2023
b2f325f
chore(deps): bump github.com/gin-gonic/gin (#1598)
dependabot[bot] Jun 25, 2023
8e5b314
chore(deps): bump github.com/gin-gonic/gin in /example/celler (#1599)
dependabot[bot] Jun 25, 2023
c8372f6
chore(deps): bump github.com/gin-gonic/gin in /example/go-module-supp…
dependabot[bot] Jun 25, 2023
0cee1c5
fix required params parsing for routes with multiple paths and multip…
Phenix66 Jul 7, 2023
fe971d2
parser: if all tags negate return true on no hits (#1624)
rsmarples Jul 17, 2023
4536bf2
fix: enums in body got parse incorrectly (#1625)
hohobilly Jul 18, 2023
575963e
parse binary literal const (#1593)
sdghchj Jul 18, 2023
1bf0078
feat: global security (#1620)
nameoffnv Jul 18, 2023
7534a13
add cli flag --pdl to determine whether parse operations in dependenc…
sdghchj Jul 18, 2023
d0f9dc5
feat: add --packagePrefix=P for only parse packages matched by prefix…
SilverRainZ Jul 19, 2023
27b27bd
enchancement: report which property is triggering a parsing error (#1…
sakishrist Jul 20, 2023
f05ccdc
add byte check before and after file is formatted (#1637)
hohobilly Aug 9, 2023
9f128b4
feat: preserve file permission when write formatted files (#1636)
hohobilly Aug 9, 2023
8ebf32f
docs(readme): fix param brace (#1647)
danielmoncada Aug 15, 2023
23c9b5c
chore(deps): bump gopkg.in/yaml.v3 (#1663)
dependabot[bot] Aug 30, 2023
e9d0aa5
yaml.v3 security patch (#1664)
ubogdan Aug 30, 2023
1460377
test: remove redundant `filepath.Clean` call (#1675)
wholesome-ghoul Sep 25, 2023
2e5d352
chore(deps): bump golang.org/x/net from 0.8.0 to 0.17.0 (#1686)
dependabot[bot] Oct 12, 2023
d23a84a
chore(deps): bump golang.org/x/net in /example/markdown (#1685)
dependabot[bot] Oct 12, 2023
2da9651
When the return value defined by the @Success tag is equal to a null …
Shimizu1111 Oct 12, 2023
d7e961a
chore(deps): bump golang.org/x/net in /example/go-module-support (#1682)
dependabot[bot] Oct 12, 2023
c00103a
chore(deps): bump golang.org/x/net in /example/object-map-example (#1…
dependabot[bot] Oct 12, 2023
2b5852a
chore(deps): bump golang.org/x/net in /example/celler (#1683)
dependabot[bot] Oct 12, 2023
bab7aac
docs: add PT and EN examples for Go generic types (#1697)
rpedrodasilva10 Nov 7, 2023
19b9c00
Update README.md (#1698)
saurabhchatterjee23 Nov 7, 2023
c7c63fc
update gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 to 3.0.0 (…
chncaption Nov 7, 2023
0ade78c
improve docker container usage (#1704)
ngehrsitz Nov 16, 2023
6cdaaf5
fix issue #1662: find definitions from external packages first (#1666)
sdghchj Nov 24, 2023
744a58e
Drop support for go v1.17.x (#1723)
sdghchj Dec 18, 2023
7603121
Add flag state #1628 (#1629)
ivolkoff Dec 18, 2023
9fdba3e
fix deps (#1724)
sdghchj Dec 19, 2023
43fec8e
chore(deps): bump golang.org/x/crypto in /example/celler (#1727)
dependabot[bot] Dec 19, 2023
fb5890c
chore(deps): bump golang.org/x/crypto in /example/go-module-support (…
dependabot[bot] Dec 19, 2023
33da992
chore(deps): bump golang.org/x/crypto in /example/object-map-example …
dependabot[bot] Dec 20, 2023
0fb6820
deprecate some parts of routers in an operation (#1735)
sdghchj Jan 11, 2024
76695ca
bug: array form filed name should not contains bracket which led to i…
Jinof Jan 16, 2024
d4218f2
Struct fields supported for header and path param types (#1740)
tanenbaum Jan 22, 2024
ae7e404
fix #1742 (#1744)
sdghchj Jan 22, 2024
7147984
Feat: Support generic with map params (#1746)
sdghchj Jan 29, 2024
98ed434
Update version.go (#1751)
sdghchj Feb 1, 2024
56fde5c
Update operation.go (#1753)
mathieu-chauvet Feb 6, 2024
928264c
fix: remove dropped tags from general infos (#1764)
sdghchj Feb 20, 2024
87e7d9c
Update docker go build version to 1.21 (#1758)
ngehrsitz Feb 20, 2024
91624ad
add support for "title" tag (#1762)
matteobassan Feb 20, 2024
90aa46f
chore: fix some typos in comments (#1788)
camcui Apr 20, 2024
8a47dcb
bump go version (#1797)
ubogdan Apr 20, 2024
0834357
chore(deps): bump golang.org/x/net from 0.17.0 to 0.23.0 (#1793)
dependabot[bot] Apr 20, 2024
d5af957
chore(deps): bump golang.org/x/net in /example/markdown (#1792)
dependabot[bot] Apr 20, 2024
1bb1445
chore(deps): bump golang.org/x/net in /example/celler (#1794)
dependabot[bot] Apr 20, 2024
6aa6613
chore(deps): bump golang.org/x/net in /example/go-module-support (#1795)
dependabot[bot] Apr 20, 2024
0368d7d
chore(deps): bump golang.org/x/net in /example/object-map-example (#1…
dependabot[bot] Apr 20, 2024
4c2f8dd
Handle case of empty GOROOT (#1798)
evan-goode Apr 21, 2024
85254b4
Added multiline support for @description attribute for securityDefini…
golandprog Apr 22, 2024
15dae35
Feat: multi-arch docker image (#1756)
tnaroska Apr 23, 2024
b8662de
chore(deps): bump google.golang.org/protobuf (#1773)
dependabot[bot] Apr 23, 2024
4a11e23
chore(deps): bump google.golang.org/protobuf (#1774)
dependabot[bot] Apr 23, 2024
937c239
chore(deps): bump google.golang.org/protobuf in /example/celler (#1775)
dependabot[bot] Apr 23, 2024
fd2fa83
fix issue: #1780: filter $GOROOT path (#1827)
bobsongplus Jun 21, 2024
e55c557
feat: read from stdin, write to stdout (#1831) (#1832)
bfbonatto Jun 21, 2024
7204462
Added suport for parsing comments inside of function bodies (#1824)
j-d-ha Jun 21, 2024
f32d4d3
adds support for complex types with function scope (#1813)
KristofferFJ Jun 28, 2024
807dd1f
[Issue 1812] fix misalignment in expected.json and api.go messing wit…
KristofferFJ Jul 1, 2024
697572a
Fixes Issue 1829 (#1830)
Kafkalasch Jul 1, 2024
ff50cd6
Fix global overrides for any/interface ref types (#1835)
ezequiel Jul 3, 2024
c7f1cd8
adds support for pointer function scoped fields (#1841)
KristofferFJ Jul 11, 2024
10030b0
fix parse nested structs and aliases (#1866)
zdon0 Aug 20, 2024
83fe3ca
Fix generics used with function scoped types (#1883)
berk-karaal Sep 5, 2024
1d730c5
Fix param comment escaping issue (#1890)
yukiomoto Sep 20, 2024
a3c6d12
support markdown description for declaration (#1893)
nicoxb Sep 25, 2024
9069105
update README (#1856)
sdghchj Oct 17, 2024
4fd8a36
Update docs for request and response headers (#1825)
eksrha Oct 17, 2024
a74d34c
fix:parse all field names declared in a row (#1872)
sdghchj Oct 17, 2024
28de14c
Flags to parse internal and dependency package (#1894)
bytesByHarsh Oct 17, 2024
7159b0f
fix: failing assert in enums test on 32bit (#1634)
leso-kn Oct 17, 2024
d323b48
Feat: Add support for parenthesis in router patterns (#1859)
alifemove Oct 17, 2024
103ac42
chore: Update ci.yml (#1902)
ubogdan Oct 17, 2024
0b9e347
new release (#1901)
ubogdan Oct 18, 2024
5b930d4
Merge branch 'v2' into v2-merge
ubogdan Oct 18, 2024
36c14a4
fix some issues
ubogdan Oct 18, 2024
6106783
fix unit tests
ubogdan Oct 19, 2024
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
Prev Previous commit
Next Next commit
Merge branch 'v2' into v2-merge
  • Loading branch information
ubogdan authored Oct 18, 2024
commit 5b930d44b4d1d1effcd70277ccb0e17f868f8ce2
84 changes: 52 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,36 +17,53 @@
Swag converts Go annotations to Swagger Documentation 2.0. We've created a variety of plugins for popular [Go web frameworks](#supported-web-frameworks). This allows you to quickly integrate with an existing Go project (using Swagger UI).

## Contents
- [Getting started](#getting-started)
- [Supported Web Frameworks](#supported-web-frameworks)
- [How to use it with Gin](#how-to-use-it-with-gin)
- [The swag formatter](#the-swag-formatter)
- [Implementation Status](#implementation-status)
- [Declarative Comments Format](#declarative-comments-format)
- [General API Info](#general-api-info)
- [API Operation](#api-operation)
- [Security](#security)
- [Examples](#examples)
- [Descriptions over multiple lines](#descriptions-over-multiple-lines)
- [User defined structure with an array type](#user-defined-structure-with-an-array-type)
- [Function scoped struct declaration](#function-scoped-struct-declaration)
- [Model composition in response](#model-composition-in-response)
- [Add request headers](#add-request-headers)
- [Add response headers](#add-response-headers)
- [Use multiple path params](#use-multiple-path-params)
- [Example value of struct](#example-value-of-struct)
- [SchemaExample of body](#schemaexample-of-body)
- [Description of struct](#description-of-struct)
- [Use swaggertype tag to supported custom type](#use-swaggertype-tag-to-supported-custom-type)
- [Use global overrides to support a custom type](#use-global-overrides-to-support-a-custom-type)
- [Use swaggerignore tag to exclude a field](#use-swaggerignore-tag-to-exclude-a-field)
- [Add extension info to struct field](#add-extension-info-to-struct-field)
- [Rename model to display](#rename-model-to-display)
- [How to use security annotations](#how-to-use-security-annotations)
- [Add a description for enum items](#add-a-description-for-enum-items)
- [Generate only specific docs file types](#generate-only-specific-docs-file-types)
- [How to use Go generic types](#how-to-use-generics)
- [About the Project](#about-the-project)
- [swag](#swag)
- [Contents](#contents)
- [Getting started](#getting-started)
- [swag cli](#swag-cli)
- [Supported Web Frameworks](#supported-web-frameworks)
- [How to use it with Gin](#how-to-use-it-with-gin)
- [The swag formatter](#the-swag-formatter)
- [Implementation Status](#implementation-status)
- [Declarative Comments Format](#declarative-comments-format)
- [General API Info](#general-api-info)
- [Using markdown descriptions](#using-markdown-descriptions)
- [Open API V3.1.0+](#open-api-v310)
- [API Operation](#api-operation)
- [Mime Types](#mime-types)
- [Param Type](#param-type)
- [Data Type](#data-type)
- [Security](#security)
- [Attribute](#attribute)
- [Available](#available)
- [Future](#future)
- [Examples](#examples)
- [Descriptions over multiple lines](#descriptions-over-multiple-lines)
- [User defined structure with an array type](#user-defined-structure-with-an-array-type)
- [Function scoped struct declaration](#function-scoped-struct-declaration)
- [Model composition in response](#model-composition-in-response)
- [Add headers in request](#add-request-headers)
- [Add headers in response](#add-a-headers-in-response)
- [Use multiple path params](#use-multiple-path-params)
- [Add multiple paths](#add-multiple-paths)
- [Example value of struct](#example-value-of-struct)
- [SchemaExample of body](#schemaexample-of-body)
- [Description of struct](#description-of-struct)
- [Use swaggertype tag to supported custom type](#use-swaggertype-tag-to-supported-custom-type)
- [Use global overrides to support a custom type](#use-global-overrides-to-support-a-custom-type)
- [Use swaggerignore tag to exclude a field](#use-swaggerignore-tag-to-exclude-a-field)
- [Add extension info to struct field](#add-extension-info-to-struct-field)
- [Rename model to display](#rename-model-to-display)
- [How to use security annotations](#how-to-use-security-annotations)
- [Add a description for enum items](#add-a-description-for-enum-items)
- [Generate only specific docs file types](#generate-only-specific-docs-file-types)
- [How to use Go generic types](#how-to-use-generics)
- [Change the default Go Template action delimiters](#change-the-default-go-template-action-delimiters)
- [About the Project](#about-the-project)
- [Contributors](#contributors)
- [Backers](#backers)
- [Sponsors](#sponsors)
- [License](#license)

## Getting started

@@ -117,11 +134,14 @@ OPTIONS:
--parseGoList Parse dependency via 'go list' (default: true)
--parseExtension value Parse only those operations that match given extension
--tags value, -t value A comma-separated list of tags to filter the APIs for which the documentation is generated.Special case if the tag is prefixed with the '!' character then the APIs with that tag will be excluded
--templateDelims value, --td value Provide custom delimiters for Go template generation. The format is leftDelim,rightDelim. For example: "[[,]]"
--v3.1 Generate OpenAPI V3.1 spec (default: false)
--templateDelims value, --td value Provide custom delimeters for Go template generation. The format is leftDelim,rightDelim. For example: "[[,]]"
--collectionFormat value, --cf value Set default collection format (default: "csv")
--state value Initial state for the state machine (default: ""), @HostState in root file, @State in other files
--parseFuncBody Parse API info within body of functions in go files, disabled by default (default: false)
--help, -h show help (default: false)
--packageName --output A package name of docs.go, using output directory name by default (check --output option)
--collectionFormat value, --cf value Set default collection format (default: "csv")
--help, -h show help
```

```bash
1 change: 1 addition & 0 deletions cmd/swag/main.go
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ const (
tagsFlag = "tags"
parseExtensionFlag = "parseExtension"
templateDelimsFlag = "templateDelims"
openAPIVersionFlag = "v3.1"
packageName = "packageName"
collectionFormatFlag = "collectionFormat"
packagePrefixFlag = "packagePrefix"
7 changes: 6 additions & 1 deletion enums_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package swag

import (

"encoding/json"
"math/bits"
"os"
@@ -17,10 +18,13 @@ func TestParseGlobalEnums(t *testing.T) {
p := New()
err = p.ParseAPI(searchDir, mainAPIFile, defaultParseDepth)
assert.NoError(t, err)

b, err := json.MarshalIndent(p.swagger, "", " ")
assert.NoError(t, err)
assert.Equal(t, string(expected), string(b))
constsPath := "github.com/swaggo/swag/testdata/enums/consts"

constsPath := "github.com/swaggo/swag/v2/testdata/enums/consts"

assert.Equal(t, bits.UintSize, p.packages.packages[constsPath].ConstTable["uintSize"].Value)
assert.Equal(t, int32(62), p.packages.packages[constsPath].ConstTable["maxBase"].Value)
assert.Equal(t, 8, p.packages.packages[constsPath].ConstTable["shlByLen"].Value)
@@ -30,4 +34,5 @@ func TestParseGlobalEnums(t *testing.T) {
assert.Equal(t, "aa\nbb\u8888cc", p.packages.packages[constsPath].ConstTable["escapestr"].Value)
assert.Equal(t, 1_000_000, p.packages.packages[constsPath].ConstTable["underscored"].Value)
assert.Equal(t, 0b10001000, p.packages.packages[constsPath].ConstTable["binaryInteger"].Value)

}
13 changes: 9 additions & 4 deletions example/markdown/go.sum
Original file line number Diff line number Diff line change
@@ -66,17 +66,20 @@ github.com/swaggo/swag v1.8.1 h1:JuARzFX1Z1njbCGz+ZytBR15TFJwF2Q7fu8puJHhQYI=
github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -85,9 +88,11 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
19 changes: 7 additions & 12 deletions example/object-map-example/go.mod
Original file line number Diff line number Diff line change
@@ -28,19 +28,14 @@ require (
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/ugorji/go/codec v1.1.13 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/tools v0.1.12 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
26 changes: 12 additions & 14 deletions example/object-map-example/go.sum
Original file line number Diff line number Diff line change
@@ -79,14 +79,12 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
@@ -123,29 +121,29 @@ github.com/swaggo/gin-swagger v1.4.2/go.mod h1:hmJ1vPn+XjUvnbzjCdUAxVqgraxELxk8x
github.com/swaggo/swag v1.7.9/go.mod h1:gZ+TJ2w/Ve1RwQsA2IRoSOTidHz6DX+PIG8GWvbnoLU=
github.com/swaggo/swag v1.8.1 h1:JuARzFX1Z1njbCGz+ZytBR15TFJwF2Q7fu8puJHhQYI=
github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go v1.1.13 h1:nB3O5kBSQGjEQAcfe1aLUYuxmXdFKmYgBZhY32rQb6Q=
github.com/ugorji/go v1.1.13/go.mod h1:jxau1n+/wyTGLQoCkjok9r5zFa/FxT6eI5HiHKQszjc=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/ugorji/go/codec v1.1.13 h1:013LbFhocBoIqgHeIHKlV4JWYhqogATYWZhIcH0WHn4=
github.com/ugorji/go/codec v1.1.13/go.mod h1:oNVt3Dq+FO91WNQ/9JnHKQP2QJxTzoN7wCBFCq1OeuU=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
@@ -176,8 +174,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
43 changes: 43 additions & 0 deletions field_parser_test.go
Original file line number Diff line number Diff line change
@@ -725,5 +725,48 @@
assert.Equal(t, 2, len(fieldnames))
assert.Equal(t, "x", fieldnames[0])
assert.Equal(t, "y", fieldnames[1])

t.Run("Pattern tag", func(t *testing.T) {
t.Parallel()

schema := spec.Schema{}
schema.Type = []string{"array"}
schema.Items = &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
},
},
}
err := newTagBaseFieldParser(
&Parser{},
&ast.Field{Tag: &ast.BasicLit{
Value: `json:"test" pattern:"^[a-zA-Z0-9_]*$"`,
}},
).ComplementSchema(&schema)
assert.NoError(t, err)
assert.Equal(t, "^[a-zA-Z0-9_]*$", schema.Pattern)
})

t.Run("Pattern tag array", func(t *testing.T) {
t.Parallel()

schema := spec.Schema{}
schema.Type = []string{"array"}
schema.Items = &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
},
},
}
err := newTagBaseFieldParser(
&Parser{},
&ast.Field{Tag: &ast.BasicLit{
Value: `json:"test" pattern:"^[a-zA-Z0-9_]*$"`,
}},
).ComplementSchema(&schema)
assert.NoError(t, err)
assert.Equal(t, "^[a-zA-Z0-9_]*$", schema.Items.Schema.Pattern)
})
}

Check failure on line 772 in field_parser_test.go

GitHub Actions / test (1.21.x, ubuntu-latest)

missing ',' before newline in argument list

Check failure on line 772 in field_parser_test.go

GitHub Actions / test (1.21.x, macos-latest)

missing ',' before newline in argument list

Check failure on line 772 in field_parser_test.go

GitHub Actions / test (1.22.x, ubuntu-latest)

missing ',' before newline in argument list
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.