-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
OpenAPI: first pass on Plugins API - Shared Links #3378
Conversation
BundleMonUnchanged files (7)
No change in files bundle size Final result: ✅ View report in BundleMon website ➡️ |
74a3b4b
to
6139dfd
Compare
a895c64
to
1c09e02
Compare
WHEN g2.page_path IS NOT NULL THEN g2.page_path | ||
WHEN g2.event_name IS NOT NULL THEN g2.event_name | ||
WHEN g2.page_path IS NOT NULL THEN 'Page: ' || g2.page_path | ||
WHEN g2.event_name IS NOT NULL THEN 'Event: ' || g2.event_name |
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.
On staging we've had goals equally named but of different types, so that's another edge case to be addressed. Ref #3343
3344a96
to
cd75183
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.
We ran this on prod in correct order, but merging was a bit careless and reversed it
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.
As you said - OpenAPI specs are a bit verbose to define but looks good to me! Love the assert_spec
helper in tests :)
test/plausible_web/plugins/api/controllers/shared_links_test.exs
Outdated
Show resolved
Hide resolved
(to be used with path helpers once called from within forwarded router's scope)
5cce42b
to
ec9637e
Compare
Co-authored-by: Uku Taht <Uku.taht@gmail.com>
lib/plausible/plugins/api/tokens.ex
Outdated
def create(%Site{} = site, description, generate \\ Token.generate()) do | ||
with generated_token <- generate, |
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.
hmm maybe just name the argument generated_token
?
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.
nice! b7f65fe
The migration in question was renamed in order to fix order of executing migrations when run from the ground up (via #3378). As a side effect, it's executed again on databases that had it applied earlier, with a different timestamp prefix. As this migration is safe to run multiple times, it was modified to make forward migration work gracefully when constraint already exists.
* Make FixBrokenGoals migration idempotent The migration in question was renamed in order to fix order of executing migrations when run from the ground up (via #3378). As a side effect, it's executed again on databases that had it applied earlier, with a different timestamp prefix. As this migration is safe to run multiple times, it was modified to make forward migration work gracefully when constraint already exists. * Add `pending-migrations.sh` release script
Changes
This PR implements Shared Links resource exposed via the new Plugins API (work in progress, initially aiming at new Wordpress plugin integration).
The API implements OpenAPI Specification 3 (via https://hexdocs.pm/open_api_spex/readme.html) for the benefit of easier 3rd party client integration with stronger contract enforcement.
The Plugins API is served off a new router (
PlausibleWeb.Plugins.API.Router
) that requests coming to/api/plugins
are forwarded to. This is only for the sake of readability, the TCP endpoint remains the same for now.The schema is served from
/api/plugins/spec/openapi
, read by the swagger UI at/api/plugins/spec/swagger-ui
. Based on the schema, clients should be able to generate their implementations and keep them verified against the contract definition. At later stage, we'll look into generating and publishing documentation from it, for now the swagger UI should be good enough.At later stage, incorporating schema generation into our CI flow will help us detect any breaking changes (we'll be able to compare the base schema to the PR submitted for example).
API authentication is done via tokens, carried over in the
authorization
header, implemented via #3373 and #3370.The UI for provisioning authentication tokens will be done in a separate PR. Currently the
Plausible.Plugins.API.Tokens.create/2
function can be used to play with the API locally.Tests
Changelog
Documentation
Dark mode