Skip to content

Conversation

krororo
Copy link
Contributor

@krororo krororo commented Apr 28, 2025

This PR fixes an issue where specifying a class like Time for the type option in expose documentation resulted in an error instead of generating the correct Swagger/OpenAPI specification.

This functionality was working correctly in v0.5.5 but regressed after PR #75, leading to the following error:

GrapeSwagger::Errors::UnregisteredParser:
  No parser registered for Time.

The primitive_type? method now uses GrapeSwagger::DocMethods::DataType.call to resolve the type name before checking if it's a primitive type.
This ensures that types like Time are correctly identified as strings with the date-time format, restoring the previous behavior.

@numbata Could you please take a look at this PR when you have a chance?

This commit fixes an issue where specifying a class like `Time`
for the `type` option in `expose` documentation resulted in an error
instead of generating the correct Swagger/OpenAPI specification.

This functionality was working correctly in v0.5.5 but regressed
after PR ruby-grape#75, leading to the following error:

```
GrapeSwagger::Errors::UnregisteredParser:
  No parser registered for Time.
```

The `primitive_type?` method now uses
`GrapeSwagger::DocMethods::DataType.call` to resolve the type
name before checking if it's a primitive type.
This ensures that types like `Time` are correctly identified as
strings with the `date-time` format, restoring the previous behavior.
Copy link
Collaborator

@numbata numbata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch and nice work switching to DataType.call, and thanks for the spec addition, @krororo

LGTM! 🚀

@dblock dblock merged commit cac04bc into ruby-grape:master Apr 29, 2025
20 checks passed
@dblock
Copy link
Member

dblock commented Apr 29, 2025

@numbata thanks for reviewing this and your past contributions, want to help maintain this gem? make a release? drop me a note to dblock at dblock dot org with your rubygems account name if so

@krororo krororo deleted the fix-type-class branch April 29, 2025 09:50
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.

3 participants