Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Additional DSL #140

Open
MarkMurphy opened this issue May 9, 2017 · 1 comment
Open

Feature Request: Additional DSL #140

MarkMurphy opened this issue May 9, 2017 · 1 comment

Comments

@MarkMurphy
Copy link

I really like the DSL Amber Feng form Stripe outlined in this blog post. Would love to see this project add support for something like that, ie. required, document, etc.

eg.

class ChargeCreateMethod < AbstractAPIMethod
  required :amount, :integer
  required :card_number, :string

  document :amount, "Amount, in cents."
  document :card_number, "The card number."

  resource ChargeAPIResource

  def execute
    create_charge(amount, card_number)
  end
end

class ChargeAPIResource < AbstractAPIResource
  required :id, :string
  required :amount, :integer
  required :card_number, :string
  required :success, :boolean

  def describe_card_number
    charge.redacted_card_number
  end
end

A good UX design principle is that you should make it really hard for your users to mess up or do the wrong thing. Why not apply this toward building the API as well?

One thing that we did that I thought was really cool was a system for documenting our API. To try to address "I forgot to update the docs!" syndrome, we made it really hard to forget by putting the documentation right under the code that adds a new property.

Our documentation then auto-generates itself from these specs—for changing most things, there's no need to go dig up static HTML files.

Source: Amber Feng - Move Fast, Don't Break Your API

@taylorthurlow
Copy link

You might be interested in my fork of this project: https://github.com/taylorthurlow/interaktor

It's not production-ready but at least you might have some opinions on how I'm doing things over there.

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

No branches or pull requests

2 participants