Skip to content

Array of string enums in query parameter #123

Answered by vearutop
dchenz asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, enum= should be enum: in field tag, but that would still be something you don't want.
Field tags are applied to fields, you want enum for an item of a slice that's held by the field.

There is no attempt to apply filed tags to field sub elements, because that would be a misleading behavior due to large variety of possible kinds of sub elements with undefined expectations, e.g. [][]string, []int, map[string]map[int]bool, etc...

https://go.dev/play/p/bn12aLBhtiK

package main

import (
	"encoding/json"
	"net/http"

	"github.com/swaggest/openapi-go/openapi31"
)

func main() {
	r := openapi31.NewReflector()

	type req struct {
		Color []string `query:"color" nullable:"false" explode:"fal…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@vearutop
Comment options

Answer selected by dchenz
@dchenz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants