-
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.
fix: fixed definition parsing for alias types (#1688)
- Loading branch information
Showing
7 changed files
with
177 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package api | ||
|
||
import "net/http" | ||
|
||
// @Router /test [GET] | ||
// @Produce json | ||
// @Success 200 {object} types.Response "Success" | ||
func Handle(w http.ResponseWriter, r *http.Request) { | ||
|
||
} |
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,110 @@ | ||
{ | ||
"openapi": "3.1.0", | ||
"info": { | ||
"title": "Swagger Example API", | ||
"version": "1.0" | ||
}, | ||
"externalDocs": { | ||
"description": "", | ||
"url": "" | ||
}, | ||
"components": { | ||
"schemas": { | ||
"types.NestedStruct": { | ||
"type": "object", | ||
"properties": { | ||
"int": { | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"types.Struct": { | ||
"type": "object", | ||
"properties": { | ||
"string": { | ||
"type": "string" | ||
}, | ||
"nestedStruct": { | ||
"$ref": "#/components/schemas/types.NestedStruct" | ||
} | ||
} | ||
}, | ||
"types.StructAlias": { | ||
"type": "object", | ||
"properties": { | ||
"string": { | ||
"type": "string" | ||
}, | ||
"nestedStruct": { | ||
"$ref": "#/components/schemas/types.NestedStruct" | ||
} | ||
} | ||
}, | ||
"types.StructSubtype": { | ||
"type": "object", | ||
"properties": { | ||
"string": { | ||
"type": "string" | ||
}, | ||
"nestedStruct": { | ||
"$ref": "#/components/schemas/types.NestedStruct" | ||
} | ||
} | ||
}, | ||
"types.OtherStructAlias": { | ||
"type": "object", | ||
"properties": { | ||
"float": { | ||
"type": "number" | ||
} | ||
} | ||
}, | ||
"types.OtherStructSubtype": { | ||
"type": "object", | ||
"properties": { | ||
"float": { | ||
"type": "number" | ||
} | ||
} | ||
}, | ||
"types.Response": { | ||
"type": "object", | ||
"properties": { | ||
"struct": { | ||
"$ref": "#/components/schemas/types.Struct" | ||
}, | ||
"structAlias": { | ||
"$ref": "#/components/schemas/types.StructAlias" | ||
}, | ||
"structSubtype": { | ||
"$ref": "#/components/schemas/types.StructSubtype" | ||
}, | ||
"otherStructAlias": { | ||
"$ref": "#/components/schemas/types.OtherStructAlias" | ||
}, | ||
"otherStructSubtype": { | ||
"$ref": "#/components/schemas/types.OtherStructSubtype" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"paths": { | ||
"/test": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/types.Response" | ||
} | ||
} | ||
}, | ||
"description": "Success" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 main | ||
|
||
// @title Swagger Example API | ||
// @version 1.0 |
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,5 @@ | ||
package othertypes | ||
|
||
type Struct struct { | ||
Float float64 | ||
} |
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 types | ||
|
||
import "github.com/swaggo/swag/v2/testdata/v3/type_alias_definition/othertypes" | ||
|
||
type Struct struct { | ||
String string `json:"string"` | ||
NestedStruct NestedStruct `json:"nestedStruct"` | ||
} | ||
|
||
type NestedStruct struct { | ||
Int int `json:"int"` | ||
} | ||
|
||
type StructAlias = Struct | ||
type OtherStructAlias = othertypes.Struct | ||
|
||
type StructSubtype Struct | ||
type OtherStructSubtype othertypes.Struct | ||
|
||
type Response struct { | ||
Struct `json:"struct"` | ||
StructAlias `json:"structAlias"` | ||
OtherStructAlias `json:"otherStructAlias"` | ||
StructSubtype `json:"structSubtype"` | ||
OtherStructSubtype `json:"otherStructSubtype"` | ||
} |