Skip to content

Swagger JSON cannot parse Array of Hash in params #895

@RIstiaque

Description

@RIstiaque

When inputting the following code for a method:

  param :param_1, Array, of: Hash, desc: 'Array of Objects', required: true do
    param :param_2, String, required: true
    param :param_3, String, required: false
  end

It outputs the following after running this command: rails apipie:static_swagger_json:
image

However in the response, there is the array_of property which allows me to make an array_of: Hash:

  returns code: 200 do
    property :array_1, array_of: Hash, desc: 'Array of Objects', required: true do
      property :prop_1, String
      property :prop_2, String
    end
  end

Which results in the following:
image

Is there a reason that the array_of is only limited to responses?

After forking and cloning APIPie locally, I uncommented this line:

raise "an ':array_of =>' validator is allowed exclusively on response-only fields" unless @response_only

And was able to get the first piece of code working after refactoring to array_of: Hash.

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