Skip to content

Using swagger:strfmt on a []byte type (UUID) infers the type as an array of strings #2627

@chanced

Description

@chanced

Problem statement

Using // swagger:strfmt on a []byte type (UUID) infers the type as an array of strings.

I have a local version of uuid.UUID which is [16]byte under the hood. Using // swagger:strfmt uuid4 gets the type close but it is reflecting a slice/array of strings instead of a string value.

I've tried setting // swagger:type string on both the type and the property but neither have had an effect.

Swagger specification

definitions:
  Base:
    properties:
      _id:
        items:
          format: uuid4
          type: string
        type: array
        x-go-name: Identifier

Steps to reproduce

import "github.com/google/uuid"

// ID is a UUIDv4
// swagger:strfmt uuid4
// can not set swagger type here either
type ID uuid.UUID

//swagger:model base
type Base struct {
         // ↓ has no effect
	// swagger:type string
	Identifier    ID `json:"_id" bson:"_id"`
}
swagger generate spec -o swagger.yaml --scan-models

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions