From 9236b8a39798c8ecec3ba8cca64131a9b7e5d076 Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 12 May 2022 17:54:01 +0800 Subject: [PATCH] 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 --- package.json | 2 +- test/e2e-api/admin/posts.test.js | 8 ++++---- yarn.lock | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 60ff836a0a..17d1244cde 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/e2e-api/admin/posts.test.js b/test/e2e-api/admin/posts.test.js index 55d4f45e76..3693871396 100644 --- a/test/e2e-api/admin/posts.test.js +++ b/test/e2e-api/admin/posts.test.js @@ -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; diff --git a/yarn.lock b/yarn.lock index edf863cf54..471060e340 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"