openstax_api 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6f67ec575e9990383aa7c21478d981e5e70bb9a
4
- data.tar.gz: 5430de9cbcebbca7ceae0fd2778f810058a4097c
3
+ metadata.gz: 3c1cb250aa64fa4c52fabc8df85b84382dbfa073
4
+ data.tar.gz: 9965f611b7b19b5374b164be159f44623ae419a5
5
5
  SHA512:
6
- metadata.gz: 63333b1fc1570bb53c0635aa78be1d2f323201c49c01d7d8d445c64542c6416792b58d2aced1cb44bffb716379352868f7d046d601e1f90dd69e2d31c0b69bd1
7
- data.tar.gz: 7aa5032b8569f8b567e5de1d081e3de56e2773bf2957fe6b8626f50d279a656e0f868e6bb5d649878da3ca30965fb19ec300fb15ae14c34add1875b1ceb8f123
6
+ metadata.gz: 3e137dd7072ffa37e0e1bf64573e707189e6bb52a66f9d4286e4efcd5ea58aa40e3c6b1adc32f7b1f9873f62c7d9c63ea00c3b7b9a3dfa45f13fde0fbcd13cec
7
+ data.tar.gz: 50131d6aa0fbf79facab24015f420fa912cbd9b395989fa9865240cccf1382b65f35da8571d117f206905c3b0098f2e1557f1cdbea46a581c2455e699f0a3ea2
@@ -8,7 +8,7 @@ module OpenStax
8
8
  include OpenStax::Api::Roar
9
9
  include OpenStax::Api::Apipie
10
10
 
11
- doorkeeper_for :all, :unless => :session_user?
11
+ before_action :doorkeeper_authorize!, :unless => :session_user?
12
12
  skip_before_filter :verify_authenticity_token, :unless => :session_user?
13
13
 
14
14
  respond_to :json
@@ -34,6 +34,12 @@ module OpenStax
34
34
  current_api_user.human_user
35
35
  end
36
36
 
37
+ def consume!(model, options = {})
38
+ # Don't error out if no CONTENT_TYPE header
39
+ request.env['CONTENT_TYPE'] ||= 'application/json'
40
+ super
41
+ end
42
+
37
43
  protected
38
44
 
39
45
  def session_user?
@@ -10,7 +10,7 @@ module OpenStax
10
10
  module V1
11
11
  class AbstractSearchRepresenter < ::Roar::Decorator
12
12
 
13
- include ::Roar::Representer::JSON
13
+ include ::Roar::JSON
14
14
 
15
15
  property :total_count,
16
16
  type: Integer,
@@ -31,7 +31,8 @@ module OpenStax
31
31
 
32
32
  if model.save
33
33
  respond_with model, represent_with: represent_with,
34
- status: :created
34
+ status: :created,
35
+ location: [:api, model]
35
36
  else
36
37
  render_api_errors(model.errors)
37
38
  end
@@ -72,7 +73,7 @@ module OpenStax
72
73
  OSU::AccessPolicy.require_action_allowed!(:destroy,
73
74
  current_api_user,
74
75
  model)
75
-
76
+
76
77
  if model.destroy
77
78
  head :no_content
78
79
  else
@@ -44,7 +44,8 @@ module OpenStax
44
44
  header = is_a_controller_spec? ? request.env : {}
45
45
 
46
46
  # Add the doorkeeper token info
47
- header['HTTP_AUTHORIZATION'] = "Bearer #{doorkeeper_token.token}" if doorkeeper_token
47
+ header['HTTP_AUTHORIZATION'] = "Bearer #{doorkeeper_token.token}" \
48
+ if doorkeeper_token
48
49
 
49
50
  # Select the version of the API based on the spec metadata and populate the accept header
50
51
  version_string = self.class.metadata[:version].try(:to_s)
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Api
3
- VERSION = "5.0.1"
3
+ VERSION = "5.1.0"
4
4
  end
5
5
  end
@@ -1,8 +1,8 @@
1
1
  require 'representable/json'
2
2
 
3
- class UserRepresenter < ::Roar::Decorator
3
+ class UserRepresenter < Roar::Decorator
4
4
 
5
- include Roar::Representer::JSON
5
+ include Roar::JSON
6
6
 
7
7
  property :username, readable: false, writeable: false,
8
8
  schema_info: { required: true }
Binary file