grape-jsonapi
grape-jsonapi copied to clipboard
Improvement suggestions: Support UUID in swagger parser
The Swagger parser inherently believes all ID fields to be integers and doesn't support when we set a UUID instead. Our current solution is to monkey patch the parser. It would be ideal if we can set some magic comment that lets the parser know this id is gonna be a UUID.
Something of a proposal for the interface.
class TransactionSerializer < BaseSerializer
# id: :uuid
belongs_to :user
has_one :item
attribute :created_at do |object|
object.created_at.iso8601
end
attribute :updated_at do |object|
object.updated_at.iso8601
end
end
# or
desc "Transactions" do
success code: 200, model: TransactionSerializer, is_collection: true, id: :uuid
produces [ "application/vnd.api+json" ]
consumes [ "application/vnd.api+json" ]
headers Authorization: {
description: "Authorization token for the current user(JWT).",
required: true
}
end
@code-bunny I'd keep the default parser simple, but if you really need this feel free to create a pull request with what you would like to see changed 🙏