Skip to content

Add support for slice of byte as example #379

Closed
@prometherion

Description

I'm accepting a payload made of a slice of byte ([]byte) but providing the example as string it's not rendered correctly.

Definition of the struct:

type MyBinding struct {
	Crt []byte `json:"crt" example:"-----BEGIN CERTIFICATE-----(...)-----END CERTIFICATE-----"`
	Key []byte `json:"key" example:"-----BEGIN RSA PRIVATE KEY-----(...)-----END RSA PRIVATE KEY-----"`
}

Rendered swagger definition

        "models.MyBinding": {
            "type": "object",
            "properties": {
                "crt": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "key": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                }
            }
        },

Describe the solution you'd like
I'd like to get the example data already base64 encoded

Describe alternatives you've considered
Maybe using string but for this kind of scenarios (like PKI) it's not so elegant.

Additional context
Nothing to add.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions