Closed gabegibbturion closed 2 weeks ago
I'm also experiencing this, what was working in v1, and oon an openapi spec v2, does not work in v2 with --v3.1
I had something like this
// @Success 200 {object} PaginatedResult{data=[]Product}
Which would generate soetihng like this
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/PaginatedResult"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/Product"
}
}
}
}
]
}
},
However in V2 with --3.1 it generates the following
"200": {
"content": {
"application/json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/data"
}
],
"properties": {
"data": {
"description": "Paginated data"
},
"limit": {
"description": "Requested elements per page",
"type": "integer"
},
"page": {
"description": "Requested page number",
"type": "integer"
},
"totalElements": {
"description": "Total elements in the database for given filters",
"type": "integer"
},
"totalPages": {
"description": "Total pages of elements given limit and filters",
"type": "integer"
}
},
"type": "object"
}
}
},
"description": "OK"
},
Where the data schema is something that appears to get conflicted over multiple times, thus it is actually something like this
"data": {
"properties": {
"data": {
"items": {
"$ref": "#/components/schemas/User"
},
"type": "array"
}
},
"type": "object"
},
I did some reading and trying things out
Ultimately this now works
// @Success 200 {object} presentation.PaginatedResult[presentation.User]
Making use of generics https://github.com/swaggo/swag?tab=readme-ov-file#how-to-use-generics https://github.com/swaggo/swag/blob/master/testdata/generics_nested/api/api.go https://github.com/swaggo/swag/blob/master/testdata/generics_nested/web/handler.go
I did some reading and trying things out
Ultimately this now works
// @Success 200 {object} presentation.PaginatedResult[presentation.User]
Making use of generics https://github.com/swaggo/swag?tab=readme-ov-file#how-to-use-generics https://github.com/swaggo/swag/blob/master/testdata/generics_nested/api/api.go https://github.com/swaggo/swag/blob/master/testdata/generics_nested/web/handler.go
That worked thanks!
Versions Swaggo - github.com/swaggo/swag/v2 v2.0.0-rc3 Go - 1.21 Parse command - swag init --parseDependency --parseInternal --v3.1 --tags Imaging-Missions,Opportunities,Images,Tasking-Orders
Describe the bug When using an interface return type
and two different handlers that implement its own version of the interface
I get an issue where the tasking orders overrides the opportunities return, causing every version of PaginationResult to only return TaskingOrders. This was not an issue on the main branch but only seemed to arise when using v2. Is there something I am doing wrong? Is this a bug? I have more handlers, where taking Tasking Orders away just makes the rest default to only opportunity.