Skip to content

Improvement suggestions: Support UUID in swagger parser #52

Open
@code-bunny

Description

@code-bunny

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions