openapi-parser icon indicating copy to clipboard operation
openapi-parser copied to clipboard

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

Open Sadzeih opened this issue 5 years ago • 1 comments

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

Sadzeih avatar Oct 23 '20 08:10 Sadzeih

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!

denouche avatar Nov 24 '20 19:11 denouche