discourse/spec
Blake Erickson 7434116933
DEV: Add schema checking to api doc testing (#11721)
* DEV: Add schema checking to api doc testing

This commit improves upon rswag which lacks schema checking. rswag
really only checks that the https status matches, but this change adds
in the json-schema_builder gem which also has schema validation.

Now we can define schemas for each of our requests/responses in the
`spec/requests/api/schemas` directory which will make our documentation
specs a lot cleaner.

If we update a serializer by either adding or removing an attribute the
tests will now fail (this is a good thing!). Also if you change the type
of an attribute say from an array to a string the tests will now fail.
This will help significantly with keeping the docs in sync with actual
code changes! Now if you change how an endpoint will respond you will
have to update the docs too in order for the tests to pass. :D

This PR is inspired by:

 https://www.tealhq.com/post/how-teal-keeps-their-api-tests-and-documentation-in-sync

* Swap out json schema validator gem

Swapped out the outdated json-schema_builder gem with the json_schemer
gem.

* Add validation fields to schema

In order to have "strict" validation we need to add
`additionalProperties: false` to the schema, and we need to specify
which attributes are required.

Updated the debugging test output to print out the error details if
there are any.
2021-01-21 16:28:08 -07:00
..
components FIX: Embedded comments should only return regular posts (#11773) 2021-01-21 12:47:03 -05:00
fabricators FIX: Change default for IncomingEmail#created_via to 0 (unknown) and make NOT NULL (#11782) 2021-01-21 12:59:50 +10:00
fixtures FIX: Use ImageMagick to detect animated images (#11702) 2021-01-13 19:01:30 +02:00
helpers UX: Use appropriate logo on static pages (#11211) 2020-11-12 10:50:55 -08:00
import_export FEATURE: Rake task to export groups (#9450) 2020-04-17 14:59:54 -07:00
initializers FIX: We need to skip users with associated reviewables when auto-approving (#9080) 2020-03-02 14:33:52 -05:00
integration DEV: Change Topic Timer from enqueue_at scheduled jobs to incrementally executed jobs (#11698) 2021-01-19 13:30:58 +10:00
integrity DEV: Add i18n fallback specs (#11669) 2021-01-08 17:47:28 +01:00
jobs DEV: IMAP debugging improvements (#11784) 2021-01-21 11:37:47 +10:00
lib FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
mailers FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
models FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
multisite FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
requests DEV: Add schema checking to api doc testing (#11721) 2021-01-21 16:28:08 -07:00
script/import_scripts DEV: add specs for Vanilla import script improvements (#11712) 2021-01-16 19:35:19 +05:30
serializers UX: warn about messages to be orphaned while deleting a group. (#11727) 2021-01-22 03:29:34 +05:30
services FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
support DEV: Change Topic Timer from enqueue_at scheduled jobs to incrementally executed jobs (#11698) 2021-01-19 13:30:58 +10:00
tasks FIX: remove migrate_from_s3 task that silently corrupts data (#11703) 2021-01-17 22:33:29 +01:00
views/omniauth_callbacks FEATURE: Use full page redirection for all external auth methods (#8092) 2019-10-08 12:10:43 +01:00
rails_helper.rb DEV: Update `DB.after_commit` to be compatible with 'real' transactions (#11294) 2020-12-08 11:03:31 +11:00
swagger_helper.rb DEV: Add schema checking to api doc testing (#11721) 2021-01-21 16:28:08 -07:00