grape-swagger-entity icon indicating copy to clipboard operation
grape-swagger-entity copied to clipboard

Support `additionalProperties`

Open olivier-thatch opened this issue 8 months ago • 0 comments

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.

olivier-thatch avatar May 08 '25 00:05 olivier-thatch