Skip to content

Commit

Permalink
Allow additionalProperties in jsonapi schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Marahin committed Oct 2, 2020
1 parent 9c36245 commit e9f8b7b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/jsonapi_parameters/jsonapi_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"$ref": "#/definitions/jsonapi"
}
},
"additionalProperties": false
"additionalProperties": true
},
"failure": {
"type": "object",
Expand All @@ -75,7 +75,7 @@
"$ref": "#/definitions/links"
}
},
"additionalProperties": false
"additionalProperties": true
},
"info": {
"type": "object",
Expand All @@ -93,7 +93,7 @@
"$ref": "#/definitions/jsonapi"
}
},
"additionalProperties": false
"additionalProperties": true
},

"meta": {
Expand Down Expand Up @@ -148,7 +148,7 @@
"$ref": "#/definitions/meta"
}
},
"additionalProperties": false
"additionalProperties": true
},
"relationshipLinks": {
"description": "A resource object **MAY** contain references to other resource objects (\"relationships\"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.",
Expand Down Expand Up @@ -213,7 +213,7 @@
{"required": ["type"]}
]
},
"additionalProperties": false
"additionalProperties": true
},

"relationships": {
Expand Down Expand Up @@ -251,10 +251,10 @@
{"required": ["type"]}
]
},
"additionalProperties": false
"additionalProperties": true
}
},
"additionalProperties": false
"additionalProperties": true
},
"relationshipToOne": {
"description": "References to other resource objects in a to-one (\"relationship\"). Relationships can be specified by including a member in a resource's links object.",
Expand Down Expand Up @@ -297,7 +297,7 @@
"$ref": "#/definitions/meta"
}
},
"additionalProperties": false
"additionalProperties": true
},
"pagination": {
"type": "object",
Expand Down Expand Up @@ -344,7 +344,7 @@
"$ref": "#/definitions/meta"
}
},
"additionalProperties": false
"additionalProperties": true
},

"error": {
Expand Down Expand Up @@ -390,7 +390,7 @@
"$ref": "#/definitions/meta"
}
},
"additionalProperties": false
"additionalProperties": true
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions spec/lib/jsonapi_parameters/validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,23 @@ class Translator
expect { validator.validate! }.to raise_error(ActiveModel::ValidationError)
end
end

describe 'Rails specific parameters' do
it 'does not yield validation error on :controller, :action, :commit' do
rails_specific_params = [:controller, :action, :commit]
payload = { controller: 'examples_controller', action: 'create', commit: 'Sign up' }
validator = described_class.new(payload)

expect { validator.validate! }.to raise_error(ActiveModel::ValidationError)

begin
validator.validate!
rescue ActiveModel::ValidationError => err
rails_specific_params.each do |param|
expect(err.message).not_to include("Payload path '/#{param}'")
end
end
end
end
end
end

0 comments on commit e9f8b7b

Please sign in to comment.