make _type in schema indicate the schemas type

instead of indicating that the described resource has something
called "_type"
pull/2655/head
Jan Sandbrink 10 years ago
parent 52696b5c98
commit 2bbcaf3fd6
  1. 1
      config/locales/de.yml
  2. 1
      config/locales/en.yml
  3. 19
      doc/apiv3-documentation.apib
  4. 4
      lib/api/decorators/schema.rb
  5. 4
      lib/api/v3/work_packages/form/work_package_payload_representer.rb
  6. 9
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb
  7. 2
      spec/lib/api/v3/work_packages/form/work_package_payload_representer_spec.rb
  8. 8
      spec/lib/api/v3/work_packages/work_package_schema_representer_spec.rb

@ -1676,7 +1676,6 @@ de:
api_v3:
attributes:
_type: "Ressourcenart"
lock_version: "Sperrversion"
errors:
code_401: "Sie müssen sich authentifizieren, um auf die Ressource zugreifen zu können."

@ -1667,7 +1667,6 @@ en:
api_v3:
attributes:
_type: "Resource Type"
lock_version: "Lock Version"
errors:
code_401: "You need to be authenticated to access this resource."

@ -767,7 +767,7 @@ contain a default value for that property. Nevertheless the client will also rec
The content of this element *can* be used as a template for the request body of a call to **validate** or **commit**.
A call to **validate** and **commit** does not need to include all properties that were defined in the `payload` section.
It is only necessary to include the properties that you want to change, as well as the `_type` and a `lockVersion` if one is present.
It is only necessary to include the properties that you want to change, as well as the `lockVersion` if one is present.
However you *may* include all the properties sent in the `payload` section.
### Schema
@ -830,10 +830,6 @@ That is because the main purpose of a form is helping the client to sort out val
"type": "Integer",
"writable": false
},
"_type": {
"type": "MetaType",
"writable": false
},
"subject": {
"type": "String",
"minLength": 1,
@ -1608,6 +1604,7 @@ Note that regular expressions used in the API follow the rules of [Ruby Regular
+ Body
{
"_type": "Schema",
"_links": {
"self": { "href": "/api/v3/example/schema" }
},
@ -1617,11 +1614,6 @@ Note that regular expressions used in the API follow the rules of [Ruby Regular
"type": "Integer",
"writable": false
},
"_type": {
"name": "Resource Type",
"type": "MetaType",
"writable": false
},
"subject": {
"name": "Subject",
"type": "String",
@ -2767,10 +2759,8 @@ the human readable name of custom fields.*
When calling this endpoint the client provides a single object, containing the properties and links that it wants to change, in the body.
Note that it is only allowed to provide properties or links supporting the **write** operation.
Additionally to the fields the client wants to change, it is mandatory to provide:
* The `_type` which should as of now always be `WorkPackage`
* The value of `lockVersion` which was received by the `GET` request this change originates from
Additionally to the fields the client wants to change, it is mandatory to provide the value of `lockVersion` which was received
by the `GET` request this change originates from.
The value of `lockVersion` is used to implement [optimistic locking](http://en.wikipedia.org/wiki/Optimistic_concurrency_control).
@ -2784,7 +2774,6 @@ The value of `lockVersion` is used to implement [optimistic locking](http://en.w
+ Request (application/json)
{
"_type": "WorkPackage",
"lockVersion": 13,
"subject": "Lorem"
"parentId": "42"

@ -142,6 +142,10 @@ module API
self.class.represented_class.human_attribute_name(object)
end
end
def _type
'Schema'
end
end
end
end

@ -120,10 +120,6 @@ module API
property :updated_at,
getter: -> (*) { nil }, render_nil: false
def _type
'WorkPackage'
end
private
def datetime_formatter

@ -59,11 +59,6 @@ module API
end
end
schema :_type,
type: 'MetaType',
name_source: -> (*) { I18n.t('api_v3.attributes._type') },
writable: false
schema :lock_version,
type: 'Integer',
name_source: -> (*) { I18n.t('api_v3.attributes.lock_version') },
@ -194,10 +189,6 @@ module API
def current_user
context[:current_user]
end
def _type
'MetaType'
end
end
end
end

@ -43,8 +43,6 @@ describe ::API::V3::WorkPackages::Form::WorkPackagePayloadRepresenter do
context 'generation' do
subject(:generated) { representer.to_json }
it { is_expected.to include_json('WorkPackage'.to_json).at_path('_type') }
describe 'work_package' do
it { is_expected.to have_json_path('subject') }

@ -50,12 +50,8 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
subject(:generated) { representer.to_json }
describe '_type' do
it_behaves_like 'has basic schema properties' do
let(:path) { '_type' }
let(:type) { 'MetaType' }
let(:name) { I18n.t('api_v3.attributes._type') }
let(:required) { true }
let(:writable) { false }
it 'is indicated as Schema' do
is_expected.to be_json_eql('Schema'.to_json).at_path('_type')
end
end

Loading…
Cancel
Save