swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.58k stars 1.19k forks source link

Issue 1812: adds support for complex types with function scope #1813

Closed KristofferFJ closed 3 months ago

KristofferFJ commented 4 months ago

Describe the PR Building on top of: https://github.com/swaggo/swag/pull/1283 Further support for function scoped types, we will now be able to define more complex request and responses in a function scope:

package main

// @Param request body main.Fun.request true "query params" 
// @Success 200 {object} main.Fun.response
// @Router /test [post]
func Fun()  {
    type request struct {
        Name string
    }

        type child struct {
                Name string
        }

    type response struct {
        Child child
    }
}

Relation issue e.g. https://github.com/swaggo/swag/pull/118/files

Additional context I do not have a lot of experience with this project, so any input is more than welcome.

KristofferFJ commented 4 months ago

@ubogdan Any chance you have some time to take a look at this?

KristofferFJ commented 3 months ago

@sdghchj any chance you have time to give this a look? My team would very much like this functionality and it should not affect anyone not using function private structs.

sdghchj commented 3 months ago

https://github.com/swaggo/swag/actions/runs/9706896241/job/26791274790

Can you please fix the test TestParseSimpleApi1 in another PR?

KristofferFJ commented 3 months ago

https://github.com/swaggo/swag/actions/runs/9706896241/job/26791274790

Can you please fix the test TestParseSimpleApi1 in another PR?

Hey @sdghchj, thanks for taking a look. I was gone all weekend so I didn't see your message until now. I have fixed the issue here: https://github.com/swaggo/swag/pull/1836