alexjomin / openapi-parser

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

fix: don't parse non-exported fields in structs #43

Open Sadzeih opened 3 years ago

Sadzeih commented 3 years ago

This fixes a bug where having private fields would add them to the struct as "composed" fields.

This fixes the issue by not adding private fields.

Example

// @openapi:schema
type animal struct {
    species string
}

// Dog struct
// @openapi:schema
type Dog struct {
    Pet
    animal
    otherpackage.Data

    Name    string `json:"name"`
    weight  int
    friends []animal
}

:arrow_down:

    Dog:
      allOf:
      - $ref: '#/components/schemas/Pet'
      - $ref: '#/components/schemas/animal'
      - $ref: '#/components/schemas/WeirdCustomName'
      - type: object
        properties:
          name:
            type: string
    animal:
      type: object
denouche commented 3 years ago

Hello, I'm not sure to understand, the example you give is before or after? Can you give the before/after to compare? By the way you need to rebase your branch, I just merged your other PR :) Thanks!