Skip to content

query params deepObject with additionalProperties: true #1112

@dankobg

Description

@dankobg

I have this schema:

- name: properties
  in: query
  description: Filter animals by properties
  required: false
  style: deepObject
  schema:
    type: object
    additionalProperties: true

it generates this type:

Properties *map[string]interface{} `json:"properties,omitempty"`

Which is good and basically what i want, but the request validation fails for this url:
animals?properties[vaccinated]=true&properties[color]=black&properties[coat_length]=large
i get error: Invalid format for parameter properties: error assigning value to destination: error binding map: unhandled type: interface {}

If i say:

additionalProperties:
  type: string 

Then it works but the type is *map[string]string and i would manually have to go through jsonschema and loop over properties and convert types from string to bool or whatever. Is there a way to make it work with basically any object, or somehow skip validation for only that specific param?

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