New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate nodeinfo response by schema #21395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you address the build failures? Looks like you need to regenerate the Gemfile.lock
49d536e
to
f31aae7
Compare
75eb074
to
78fd3e8
Compare
e4ac3ac
to
e78d63a
Compare
9371244
to
9e8d9ae
Compare
Hi @ClearlyClaire ! Can you please check this out or ask someone to review it? |
b87c3b8
to
c4a6ee8
Compare
c4a6ee8
to
328a67e
Compare
ee97f56
to
37c5232
Compare
This pull request has merge conflicts that must be resolved before it can be merged. |
…node_info_2.0_schema.json
disable throwing errors test the schema matcher
05c7b93
to
617fff2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's a bunch of unrelated dependency updates (I made in-line comments for some of them but not all). Can you revert those changes?
617fff2
to
89ee9f6
Compare
Thanks for checking it. I think I fixed all of them. |
@ineffyble you asked for changes when this PR was a draft 3 weeks ago and you did not review it afterwards. I have to ask you again: Can you please check this out? |
@MFTabriz Claire is the one you need sign-off from, I've just been trying to help with PR hygiene :) |
Thank you @ineffyble! With your change request still open, in the list this PR was being shown as “Changes requested”. Now it's marked as "Approved" and the maintainers can easily see that everything has been taken care of. |
* add json-schema to :test in Gemfile * Create node_info_2.0_schema.json * test match_response_schema * Create match_response_schema.rb * Update nodeinfo_controller_spec.rb * Rename spec/support/node_info_2.0_schema.json to spec/support/schema/node_info_2.0_schema.json * Update match_response_schema.rb * cleanup * additionally validate the json schema itself disable throwing errors test the schema matcher * rename nodeinfo schema to nodeinfo_2.0 * use Rails.root.join to construct the path * prettify json * sync Gemfile.lock
* add json-schema to :test in Gemfile * Create node_info_2.0_schema.json * test match_response_schema * Create match_response_schema.rb * Update nodeinfo_controller_spec.rb * Rename spec/support/node_info_2.0_schema.json to spec/support/schema/node_info_2.0_schema.json * Update match_response_schema.rb * cleanup * additionally validate the json schema itself disable throwing errors test the schema matcher * rename nodeinfo schema to nodeinfo_2.0 * use Rails.root.join to construct the path * prettify json * sync Gemfile.lock
This aims to be a complete specification and source of truth for how the endpoint behaves. It specifies the responses in both happy and sad paths, error handling, and authentication and authorization handling. Use JSON-schema definitions to validate the API responses via `match_json_schema` added in mastodon#21395. There is some repeated code and abstractions here. The next step is to extract [RSpec shared_examples](https://relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples) to DRY. Another option to consider is moving towards the [`rswag` gem](https://github.com/rswag/rswag) per issue mastodon#20572.
using a new matcher
match_json_schema
which uses json-schema gem. The schema file is also validated.