nitinkumar-na
2 months agoNew Member
How do I validate the key of a object type schema | v3.0.4
I have my api.yaml like this, I want to validate that the lenght of the key of this map shouldn't be empty.
How do I do it with swagger itself. I tried the below, the code generated validates the value and not the key.
components:
schemas:
MyObject:
properties:
labels:
title: labels
type: object
additionalProperties:
type: string
minLength: 1
pattern: "^.+$"
description: JSON dictionary of labels
example:
someKey: SomeValue
someKey2: SomeValue2
x-omitempty: false
Is there a way to validate the object (HashMap) key also ?
More info:
I am using GoLang and in go a map can have a empty string as a key, that what I want to avoid, by using swagger and generated server code itself.