-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
193 additions
and
0 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
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,28 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/swaggo/swag/testdata/alias_import/data" | ||
"github.com/swaggo/swag/testdata/alias_type/types" | ||
"log" | ||
) | ||
|
||
// @Summary Get application | ||
// @Description test get application | ||
// @ID get-application | ||
// @Accept json | ||
// @Produce json | ||
// @Success 200 {object} data.ApplicationResponse "ok" | ||
// @Router /testapi/application [get] | ||
func GetApplication(c *gin.Context) { | ||
var foo = data.ApplicationResponse{ | ||
Application: types.Application{ | ||
Name: "name", | ||
}, | ||
ApplicationArray: []types.Application{ | ||
{Name: "name"}, | ||
}, | ||
} | ||
log.Println(foo) | ||
//write your code | ||
} |
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,11 @@ | ||
package data | ||
|
||
import ( | ||
typesapplication "github.com/swaggo/swag/testdata/alias_import/types" | ||
) | ||
|
||
type ApplicationResponse struct { | ||
Application typesapplication.Application `json:"application"` | ||
ApplicationArray []typesapplication.Application `json:"application_array"` | ||
ApplicationTime typesapplication.DateOnly `json:"application_time"` | ||
} |
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,71 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This is a sample server Petstore server.", | ||
"title": "Swagger Example API", | ||
"termsOfService": "http://swagger.io/terms/", | ||
"contact": { | ||
"name": "API Support", | ||
"url": "http://www.swagger.io/support", | ||
"email": "support@swagger.io" | ||
}, | ||
"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": { | ||
"/testapi/application": { | ||
"get": { | ||
"description": "test get application", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Get application", | ||
"operationId": "get-application", | ||
"responses": { | ||
"200": { | ||
"description": "ok", | ||
"schema": { | ||
"$ref": "#/definitions/data.ApplicationResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"data.ApplicationResponse": { | ||
"type": "object", | ||
"properties": { | ||
"application": { | ||
"type": "object", | ||
"$ref": "#/definitions/types.Application" | ||
}, | ||
"application_array": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/types.Application" | ||
} | ||
}, | ||
"application_time": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"types.Application": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,26 @@ | ||
package alias_import | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/swaggo/swag/testdata/alias_import/api" | ||
) | ||
|
||
// @title Swagger Example API | ||
// @version 1.0 | ||
// @description This is a sample server Petstore server. | ||
// @termsOfService http://swagger.io/terms/ | ||
|
||
// @contact.name API Support | ||
// @contact.url http://www.swagger.io/support | ||
// @contact.email support@swagger.io | ||
|
||
// @license.name Apache 2.0 | ||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html | ||
|
||
// @host petstore.swagger.io | ||
// @BasePath /v2 | ||
func main() { | ||
r := gin.New() | ||
r.GET("/testapi/application", api.GetApplication) | ||
r.Run() | ||
} |
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,9 @@ | ||
package types | ||
|
||
import "time" | ||
|
||
type Application struct { | ||
Name string | ||
} | ||
|
||
type DateOnly time.Time |