Giter VIP home page Giter VIP logo

apiculture's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apiculture's Issues

Apiculture improvements

Apiculture Improvements

General guidelines

  • short endpoints, with at most a few lines inside
  • routes should be concise and straight-forward (no nesting/wildcards/etc)
  • a thin sugar coating that can be applied to most Rack frameworks
  • some out-of-the-box middlewares for a slightly opinionated framework

Documentation

  • Document thoroughly all stuff (halt, bail, action_result + args, json etc)

Actions

  • Variables passed to action_result are instance variables in the action class
  • Consider using service objects instead and call them in the endpoint itself (get rid of actions)

Error handling

  • out-of-the-box, should just work, with only defining a mapping between errors and status codes/messages
  • door open for logging/monitoring/exception tracking

Route listing

  • List all API routes with some command (maybe grouped in Rails app)

Testing

  • RSpec matchers (call endpoint, call action etc.)
  • Integration with testing framework (allow get/post/status/halt in the action as if it is mounted in a dummy sinatra app -- maybe treat the action as a standalone Sinatra app extension?)
  • Automatic RSpec test generator?

DSL

  • Better param types

    String/Integer/etc. would look nicer as :string, :integer

param :email, 'Email address of the person', String
  • Better endpoint definition

    endpoint or just post/get instead of api_method

api_method :post, '/contacts'
  • Better required params

    route_param/required_param are not visually distinctive. Would make :required as an argument to param (the DSL would then have param/param :required/route_param)

route_param :id, 'Subscription ID'
required_param :street_and_number, 'Street and number', String
  • Better responses

    json should accept anything and make a JSON out of it (so no more json foo.to_json). We currently deal with raw_json_response/json_response/json

  • Better status codes

    Automagic messages for status codes, check http://httpstatus.es

responds_with 200, 'Contact data'
  • Better endpoint descriptions

    Automagic description, from verb and resource, according to some standards

  • Authentication/authorization helpers

    Helpers like authenticate!/authorize! (maybe in a gem extension to apiculture). Maybe even the possibility to define an endpoint as authenticated (should return 401 otherwise)

Support regexes in URL

api_method :get, '^\/transfers\/(?<id>\w+)\/(?<recipient_id>\w+)\/(?<security_hash>\w+{6})$' do |id, recipient_id, security_hash |
    bye([id, recipient_id, security_hash])
end

This now fails because the validator for route params does not understand these regexes

Feature: Output routes in "rake routes" look and feel

Something this:

routes = Alligator::V1.apiculture_stack.select{|d| d.is_a? Apiculture::ActionDefinition}
prefix = Alligator::V1.instance_variable_get(:@apiculture_mounted_at)
format = "%7s %-75s %-50s\n"
routes.each do |route|
  printf format % [route.http_verb.upcase, prefix + route.path, route.description]
end

But a little less hacky

swagger / openapi integration

Out of the box apiculture supports generating documentation in HTML format.

For more seamless cooperation with consumers of an API it would be nice if we can not only generate documentation in HTML format but also in the form of a swagger or openapi definition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.