alexjomin / openapi-parser

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

Implement new tag @openapi:example #42

Closed Sadzeih closed 3 years ago

Sadzeih commented 3 years ago

This PR implements a @openapi:example tag for examples.

Usage:

// @openapi:schema
type Character struct {
    // @openapi:example Nathan Drake
    Name string `json:"name"` // putting the tag here won't work
}

// @openapi:schema
// @openapi:example 42
type Age int

will result in:

Character:
  type: object
  properties:
    name:
      type: string
      example: Nathan Drake
Age:
  type: integer
  example: 42

Notes

The conversion only handles float types, int and uint types. Otherwise, it stays as a string.

Sikwan commented 3 years ago

Sounds useful 👍

denouche commented 3 years ago

great! thanks!