Skip to content

[example tag] Appears broken for slice types #115

@ortonomy

Description

@ortonomy

In the docs here, it explains that:

You can use additional tags. Some will be interpreted by tonic, others will be exclusively used to enrich the OpenAPI specification.

example - An example value to be used in OpenAPI specification. See section below for the demonstration on how to provide example for custom types.


I've tried this:

type MultiPointWeatherRequest struct {
	Locations []string          `query:"locations[]" binding:"required" validate:"min=1" description:"Array of latitude,longitude pairs" explode:"true" example:"45.4215,-75.6972"`
	Start     *time.Time        `query:"start"`
	End       *time.Time        `query:"end"`
	Step      *models.PointStep `query:"step"`
}

Except the example is not being used in the open API specification that is generated:

- name: locations[]
          in: query
          description: Array of latitude,longitude pairs
          schema:
            type: array
            items:
              type: string
            description: Array of latitude,longitude pairs
            minItems: 1
          style: form
          explode: true

What am I missing. I don't think this is a "custom type"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions