Skip to content

Conversation

numbata
Copy link
Collaborator

@numbata numbata commented Aug 24, 2025

This PR addresses the issue where grape-swagger-entity was not correctly parsing custom array documentation (e.g., type: 'Array[Object]'), leading to incorrect Swagger schema generation.

The fix introduces a new array_type? method that intelligently identifies various array notations (is_array, type: 'array', or type: 'Array[Object]'). This ensures that the documentation override is correctly recognized and that the generated Swagger schema accurately reflects the intended type.

Part of [#962](ruby-grape/grape-swagger#962)

- Reproduces "Empty model" error when using Grape::Entity with all hidden properties
- Tests custom documentation override with Array[Object] type
- Includes working example showing expected behavior
- Follows existing issue spec patterns in the codebase
This commit addresses a long-standing issue where array types in documentation
were not correctly parsed unless the explicit `is_array` option was used.

The primary changes are:
- A new `array_type?` method is introduced in `attribute_parser.rb` to
  intelligently check for `is_array`, `type: 'array'`, or `type: 'Array[Object]'`.
- The `parse_grape_entity_params` method in `parser.rb` is refactored to
  improve readability and reduce complexity
@numbata numbata self-assigned this Aug 24, 2025
@grape-bot
Copy link

1 Warning
⚠️ Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md.

Here's an example of a CHANGELOG.md entry:

* [#86](https://github.com/ruby-grape/grape-swagger-entity/pull/86): Fix: properly parse custom array documentation - [@numbata](https://github.com/numbata).

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants