alexjomin / openapi-parser

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

Rework spec composition to make sure to use custom names for types, also adds interface{} and external package handling #32

Closed Sadzeih closed 4 years ago

Sadzeih commented 4 years ago

This PR reworks the composition of the spec to take into account #30 and #31.

This allows you to do this:

// @openapi:schema
type Response struct {
    Data external.MoreData `json:"data"`
}

:arrow_down:

Response:
    type: object
    properties:
        data:
            $ref: '#/components/schemas/MoreData'

and

// @openapi:schema:CustomName
type RegularType struct {
 // properties
}

// openapi:schema
type Response {
    Data RegularType `json:"data"`
}

:arrow_down:

Response:
    type: object
    properties:
        data:
            $ref: '#/components/schemas/CustomName'
CustomName:
    type: object
    properties:
        # properties
Sadzeih commented 4 years ago

Sorry, this PR is actually now a lot more than what the title says. It also found a better way to do #29 and adds some support for Redoc x-groupTags

denouche commented 4 years ago

Wow, this is a great PR, thank you! Sorry for the response time. Can you rebase your branch please?

Sadzeih commented 4 years ago

No worries about the response time, we've been using my fork in the meantime. What do you want me to rebase on? I'm up to date with master.

denouche commented 4 years ago

I cannot merge it, it tells me the branch has conflicts: Screenshot from 2020-09-03 09-59-00

denouche commented 4 years ago

Indeed your branch is just ahead of 13 commits from master, there should not be conflicting... I will merge it manually.

denouche commented 4 years ago

Merged. Thank you for your contributions!