Skip to main content

Map type

Plain map

To represent object with additionalProperties ogen uses Go map type.

Map:
type: object
additionalProperties:
type: string
type Map map[string]string

Map with fixed-keys

Map with fixed-keys represent by struct with AdditionalProps field.

Map:
type: object
properties:
default:
type: integer
required:
- default
additionalProperties:
type: string
type Map struct {
Default int `json:"default"`
AdditionalProps map[string]string
}

Map with key pattern

ogen also supports pattenProperties. Decoder will populate map only with keys that matches given pattern.

Map:
type: object
patternProperties:
foo.*:
type: string
type Map map[string]string

Free-form map

Map with unspecified schema represent by map with jx.Raw values.

Map:
type: object
additionalProperties: true
type Map map[string]jx.Raw