alexjomin / openapi-parser

Simple and still naive openapi documentation generator from comments of your Go code.
18 stars 8 forks source link

feat: adds anonymous struct support #39

Closed Sadzeih closed 3 years ago

Sadzeih commented 3 years ago

This PR aims to add support for anonymous structs like this:

// @openapi:schema
type RealStruct struct {
    Anonymous struct {
    Field string `json:"field"`
    } `json:"anonymous"`
}

Or

// AnonymousArray struct
// @openapi:schema
type AnonymousArray struct {
    Data []struct {
        ID string `json:"id"`
    } `json:"data"`
}

This PR also adds a bunch of error handling where missing

Closes #37

denouche commented 3 years ago

I don't really like anonymous struct, it's not good for API contract with users, but it could be useful and you're totally right it should not panic like that. Thanks!