forked from swaggo/swag
-
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.
refactor(swag): flat project package
- Loading branch information
1 parent
d1a8e20
commit 69b53ce
Showing
8 changed files
with
38 additions
and
19 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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/swaggo/swag/gen" | ||
"github.com/urfave/cli" | ||
"os" | ||
) | ||
|
||
func main() { | ||
|
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,9 +1,8 @@ | ||
package main | ||
|
||
|
||
// @title Swagger Petstore | ||
// @version 1.0 | ||
// @description This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. | ||
// @description This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key 'special-key' to test the authorization filters. | ||
// @termsOfService http://swagger.io/terms/ | ||
|
||
// @contact.email [email protected] | ||
|
@@ -16,5 +15,4 @@ package main | |
// @schemes http https | ||
func main() { | ||
|
||
|
||
} |
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"fmt" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
|
@@ -80,7 +79,8 @@ func TestParser_ParseType(t *testing.T) { | |
} | ||
|
||
func TestGetSchemes(t *testing.T) { | ||
fmt.Println(GetSchemes("@schemes http https")) | ||
//TODO: | ||
//fmt.Println(GetSchemes("@schemes http https")) | ||
|
||
} | ||
func TestParseSimpleApi(t *testing.T) { | ||
|
@@ -261,12 +261,35 @@ func TestParseSimpleApi(t *testing.T) { | |
} | ||
|
||
func TestParsePetApi(t *testing.T) { | ||
expected:=`{ | ||
"schemes": [ | ||
"http", | ||
"https" | ||
], | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key 'special-key' to test the authorization filters.", | ||
"title": "Swagger Petstore", | ||
"termsOfService": "http://swagger.io/terms/", | ||
"contact": { | ||
"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": {} | ||
}` | ||
searchDir := "example/pet" | ||
mainApiFile := "main.go" | ||
p := New() | ||
p.ParseApi(searchDir, mainApiFile) | ||
|
||
b, _ := json.MarshalIndent(p.swagger, "", " ") | ||
//assert.Equal(t, expected, string(b)) | ||
fmt.Println(string(b)) | ||
} | ||
assert.Equal(t, expected, string(b)) | ||
//fmt.Println(string(b)) | ||
} |
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,4 +1,4 @@ | ||
package swagger | ||
package swag | ||
|
||
import ( | ||
"errors" | ||
|
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