0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Relaxed validation rules + removed unknown properties

refs https://github.com/TryGhost/Toolbox/issues/314

- The API principle guiding this change is the Robustness Principle: "be conservative in what you send, be liberal in what you accept". The API will start accepting any additional properties that are not explicitly defined in the schema for the resource and will be trimming any rogue properties that are sent in the payload
This commit is contained in:
Naz 2022-05-12 17:54:01 +08:00 committed by naz
parent 371f9996f5
commit 9236b8a397
3 changed files with 9 additions and 9 deletions

View file

@ -57,7 +57,7 @@
"dependencies": {
"@sentry/node": "6.19.7",
"@tryghost/adapter-manager": "0.2.30",
"@tryghost/admin-api-schema": "3.0.0",
"@tryghost/admin-api-schema": "3.1.0",
"@tryghost/api-version-compatibility-service": "0.4.1",
"@tryghost/bookshelf-plugins": "0.4.1",
"@tryghost/bootstrap-socket": "0.2.19",

View file

@ -503,7 +503,7 @@ describe('Posts API', function () {
.send({posts: [post]})
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(422);
.expect(200);
const model = await models.Post.findOne({
id: postId
@ -687,7 +687,7 @@ describe('Posts API', function () {
.expect(200);
const scheduledPost = scheduledRes.body.posts[0];
scheduledPost.newsletter.id.should.eql(newsletterId);
should.not.exist(scheduledPost.newsletter_id);
@ -716,7 +716,7 @@ describe('Posts API', function () {
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
const publishedPost = publishedRes.body.posts[0];
model = await models.Post.findOne({
@ -786,7 +786,7 @@ describe('Posts API', function () {
});
it('Can\'t change the newsletter_id once it has been set', async function () {
// Note: this test only works if there are members subscribed to the initial newsletter
// Note: this test only works if there are members subscribed to the initial newsletter
// (so it won't get reset when changing the post status to draft again)
let model;

View file

@ -1719,10 +1719,10 @@
dependencies:
"@tryghost/errors" "^1.2.1"
"@tryghost/admin-api-schema@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-3.0.0.tgz#e0d091b75c95450baaefa7d40a80bab3aa15e47e"
integrity sha512-F5eDQinVpew2jJMriQ0UrNegW4PWewK18ylbSGFRBax5EJPBY67A8g1nZpSmuC/gMArkIX4IVyyCtTniF6epvQ==
"@tryghost/admin-api-schema@3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-3.1.0.tgz#bdb2fa3b43e3f30987cf4c0d3f34ff1b1a21fbc8"
integrity sha512-FLLIdR1flV4jaRcPDYbuzU0Wy5sE9olHA5stvUD2TwGw2RF92IVDai88VYWdkDCaOTwMyFSPEC/2b/IVVnXqtA==
dependencies:
"@tryghost/errors" "^1.0.0"
lodash "^4.17.11"