From e62bb88561daffeb6d48a488cec2812a2e1aa4e6 Mon Sep 17 00:00:00 2001 From: Alex Vondrak Date: Tue, 2 Dec 2014 16:07:00 -0800 Subject: [PATCH 1/2] #809: UPGRADING.md entry --- UPGRADING.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/UPGRADING.md b/UPGRADING.md index 80bd5213ab..936e8b4f94 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -137,12 +137,45 @@ end For more information see [#836](https://github.com/intridea/grape/issues/836). -### Changes to Custom Validators +#### Changes to Custom Validators To implement a custom validator, you need to inherit from `Grape::Validations::Base` instead of `Grape::Validations::Validator`. For more information see [Custom Validators](https://github.com/intridea/grape#custom-validators) in the documentation. +#### Changes to routes when using `format` + +Routes will no longer get file-type suffixes added if you declare a single API `format`. For example, + +```ruby +class API < Grape::API + format :json + + get :hello do + { hello: 'world' } + end +end +``` + +Pre-0.9.1, this would respond with JSON to `/hello`, `/hello.json`, `/hello.xml`, `/hello.txt`, etc. + +Now, this will only respond with JSON to `/hello`, but will be a 404 when trying to access `/hello.json`, `/hello.xml`, `/hello.txt`, etc. + +If you declare further `content_type`s, this behavior will be circumvented. For example, the following API will respond with JSON to `/hello`, `/hello.json`, `/hello.xml`, `/hello.txt`, etc. + +```ruby +class API < Grape::API + format :json + content_type :json, 'application/json' + + get :hello do + { hello: 'world' } + end +end +``` + +See the [the updated API Formats documentation](https://github.com/intridea/grape#api-formats) and [#809](https://github.com/intridea/grape/pull/809) for more info. + ### Upgrading to >= 0.9.0 #### Changes in Authentication From f5518539668a59eeae1985e3ebe080d47e3c66c4 Mon Sep 17 00:00:00 2001 From: Alex Vondrak Date: Tue, 2 Dec 2014 16:12:28 -0800 Subject: [PATCH 2/2] #809: fix reference to new gem version number in UPGRADING.md --- UPGRADING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADING.md b/UPGRADING.md index 936e8b4f94..d63b43dca5 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -157,7 +157,7 @@ class API < Grape::API end ``` -Pre-0.9.1, this would respond with JSON to `/hello`, `/hello.json`, `/hello.xml`, `/hello.txt`, etc. +Pre-0.10.0, this would respond with JSON to `/hello`, `/hello.json`, `/hello.xml`, `/hello.txt`, etc. Now, this will only respond with JSON to `/hello`, but will be a 404 when trying to access `/hello.json`, `/hello.xml`, `/hello.txt`, etc.