-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing OpenAPI 3.1.0 spec (#1513)
* fix x-tagGroups * fix module name * change paths * refactoring * update dependencies * stuff * add log * fix finding of main file * fix broken type resolution * fix bug * clean deps * fix tool after merging upstream * use json-iterator to marshal json * fix generating of json examples * update config used by jsoniter * bump version * update dependencies * resolve merge conflicts * use newest go in docker * yep * fix gen * fix gen * update swag version * yep * fix parser * fix some tests * fix all tests * parse most of general api description * implement security scheme parsing * parse oauth2 specs * parse scopes and extensions in security schemes * extend parsing security stuff * process v3 routes * meh * find unimported types * parse basic operation info * parse primitive and object parameters * generate openapi spec * fix module name * cleanup * update version to 2.0 * fix issues that appread after merging * cleanup after merge conflicts * fix all tests * add go 1.19 to workflows * pin dockerfile to 1.19.7 * Set minimum supported Go version to 1.18.x * parse response headers * copy readme * started to implement field parser * Refactor: use RefOrSpec instead of Spec * start to add tests for operationv3 * fix tests * implement allOf with primitive types * Add NestedPrimitiveArrayType test * implement TestParseResponseCommentWithNestedFieldsV3 * add more tests * parse arrays and maps * fix implementation of map types * implement more tests * fix example docs * adjust example * fix example jsons * support array types in Parameters * implement more tests, implement correct collectionFormat handling * finish implementation of operationv3 tests * all tests green * fix parsing of security definitions * add test for generalAPI info * end of day checkin * Update example.json * fix codeSamples from file and fix creation of operations * fix resolving of schema ref errors * fix tests that broke due to fixes on model parsing * Fix creating schemes of array types of custom objects * Fix resolution of refSchemas * cleanup * update dependencies * cleanup * Update README.md reset readme.md * Update README_zh-CN.md reset readme_zh-CN * update dependency * reset test file --------- Co-authored-by: Tobias Theel <tt@fino.digital>
- Loading branch information
Showing
44 changed files
with
6,140 additions
and
277 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 |
---|---|---|
|
@@ -20,3 +20,6 @@ cover.out | |
|
||
/swag | ||
/swag.exe | ||
cmd/swag/docs/* | ||
|
||
.vscode/launch.json |
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
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 |
---|---|---|
@@ -1,32 +1,29 @@ | ||
package swag | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseGlobalEnums(t *testing.T) { | ||
searchDir := "testdata/enums" | ||
expected, err := os.ReadFile(filepath.Join(searchDir, "expected.json")) | ||
assert.NoError(t, err) | ||
|
||
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" | ||
assert.Equal(t, 64, 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) | ||
assert.Equal(t, 255, p.packages.packages[constsPath].ConstTable["hexnum"].Value) | ||
assert.Equal(t, 15, p.packages.packages[constsPath].ConstTable["octnum"].Value) | ||
assert.Equal(t, `aa\nbb\u8888cc`, p.packages.packages[constsPath].ConstTable["nonescapestr"].Value) | ||
assert.Equal(t, "aa\nbb\u8888cc", p.packages.packages[constsPath].ConstTable["escapestr"].Value) | ||
assert.Equal(t, '\u8888', p.packages.packages[constsPath].ConstTable["escapechar"].Value) | ||
err := p.ParseAPI(searchDir, mainAPIFile, defaultParseDepth) | ||
require.NoError(t, err) | ||
|
||
const constsPath = "github.com/swaggo/swag/testdata/enums/consts" | ||
table := p.packages.packages[constsPath].ConstTable | ||
require.NotNil(t, table, "const table must not be nil") | ||
|
||
assert.Equal(t, 64, table["uintSize"].Value) | ||
assert.Equal(t, int32(62), table["maxBase"].Value) | ||
assert.Equal(t, 8, table["shlByLen"].Value) | ||
assert.Equal(t, 255, table["hexnum"].Value) | ||
assert.Equal(t, 15, table["octnum"].Value) | ||
assert.Equal(t, `aa\nbb\u8888cc`, table["nonescapestr"].Value) | ||
assert.Equal(t, "aa\nbb\u8888cc", table["escapestr"].Value) | ||
assert.Equal(t, '\u8888', table["escapechar"].Value) | ||
} |
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
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
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,4 @@ | ||
package swag | ||
|
||
// CodeSamples is used to parse code samples. | ||
type CodeSamples []map[string]string |
Oops, something went wrong.