Skip to content

Support additionalProperties #83

@olivier-thatch

Description

@olivier-thatch

grape-swagger has support for additionalProperties for object-type parameters: https://github.com/ruby-grape/grape-swagger?tab=readme-ov-file#additional-properties

It would be really nice if grape-swagger-entity also supported this for object-type fields in entities.

expose :string_to_string, documentation: { type: "object", additional_properties: "string" }
# or `additional_properties: String`? Ideally both should be supported.

expose :string_to_entity, documentation: { type: "object", additional_properties: Entity }

should translate to:

"string_to_string": {
  "type": "object",
  "additionalProperties": {
    "type": "string"
  }
},
"string_to_entity": {
  "type": "object",
  "additionalProperties": {
    "$ref": "#/definitions/Entity"
  }
},

I took a brief stab at this, but handling the entity case proved tricky because I don't think grape-swagger-entity has access to the full definitions? I'm not very familiar with the code and I didn't try for very long so I might have missed something obvious.

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