Commit Graph

108 Commits

Author SHA1 Message Date
Andreas Gohr 99a3dafa39 increase API version for new call, remove unused parameter 2024-04-10 15:03:35 +02:00
Andreas Gohr fb93418dc0 remove obsolete TODO comment 2024-04-10 14:59:00 +02:00
Anushka Trivedi 885b0fb0cd
added API core.getMediaUsage 2024-03-21 21:30:51 +05:30
Andreas Gohr ba15f985c4 API: ignore charset when checking content types
We still expect all communication to be in UTF-8, but we really don't
need a charset attribute for that.

fixes #4218, replaces #4219
2024-02-22 18:22:47 +01:00
Andreas Gohr 1418a776f1 API: legacy compatibility fix
wiki.getAllPages and dokuwiki.getPagelist differed in how the last
modification timestamp was communicated.

This should fix splitbrain/dokuwiki-plugin-sync#70
2024-02-09 12:59:31 +01:00
Andreas Gohr ab86a1cdff adjust group type hint for User API response 2024-02-06 13:32:25 +01:00
Andreas Gohr 932ec837f7 fix User response object in API 2024-02-06 12:31:37 +01:00
Andreas Gohr 079b7b26fa LegacyAPI: fix return types on missing pages 2024-01-11 10:09:01 +01:00
Andreas Gohr 4385690f2a fix error handling in XMLRPC
response errors in call() need to be returned as Error not as thrown
Exception.
2024-01-11 10:01:43 +01:00
Andreas Gohr 15357ce4c4 API: fix media handling in legacy API 2024-01-10 11:07:27 +01:00
Andreas Gohr b5284271bc API: add backward compatibility to API Version 11
This adds legacy support for the old API calls. This is mostly untested
but should work. Returns might not be 100% compatible in all cases but I
did my best to return the same things as before.

This will be removed in the future of course and is just to not
completely break any API usage immeadiately.
2024-01-09 17:49:09 +01:00
Andreas Gohr d48c2b252a API: code style fixes 2024-01-07 13:41:20 +01:00
Andreas Gohr ebae58f7ac compatibility fix in ClassResolver
T_NAME_QUALIFIED is only available in PHP8+, earlier it's simply a
T_STRING
2024-01-07 13:41:19 +01:00
Andreas Gohr 5e47e6df3b API added simple JSONRPC tests 2024-01-07 13:41:19 +01:00
Andreas Gohr 12b9975326 fix XMLRPC server tests
We test against the MockAPICore now since the tests are meant to ensure
the general functionality of accepting XML and correctly calling
APICalls works, not that the API returns the right things (this is
tested in the ApiCore tests).
Since we no longer use dates but always integers, we no longer need to
handle that.
2024-01-07 13:41:19 +01:00
Andreas Gohr d1f06eb4f0 API: ApiCore tests fixed and extended 2024-01-07 13:41:19 +01:00
Andreas Gohr 7de5ac5588 Another argument parsing fix for ApiCall
When using named parameters, you can expect to be able to leave out any
optional parameter and have it take it's default, even when you specify
another "later" parameter. Luckily we already know all the defaults from
reflection anyway.
2024-01-07 13:41:19 +01:00
Andreas Gohr 04acbb6fa7 API: fix named parameter handling in APICall
We cannot set missing paramerers to null. We need to make sure they are
not set at all.
2024-01-07 13:41:19 +01:00
Andreas Gohr 8268b284d4 API: make responses sortable
All responses now need to implement __toString() so they can be easily
sorted or printed.
2024-01-07 13:41:19 +01:00
Andreas Gohr 9e6b19e662 API: fix listPages
Not all needed fields are returned by the search callback
2024-01-07 13:41:19 +01:00
Andreas Gohr 5bef72bebd API: getPageHistory is nicer than getPageVersions 2024-01-07 13:41:19 +01:00
Andreas Gohr 0eb4820cfa API: checkPage needs to consider revision 2024-01-07 13:41:19 +01:00
Andreas Gohr b115d6dbc1 API: always pass revision as integer 2024-01-07 13:41:19 +01:00
Andreas Gohr 7288c5bd99 API fix depth handling in listPages 2024-01-07 13:41:19 +01:00
Andreas Gohr 58ae4747de API: initialize responses explicitly
Instead of passing unknown arrays, explicit parameters are passed.
Revision handling should now work correctly since we can pass revision=0
but a mtime.
2024-01-07 13:41:19 +01:00
Andreas Gohr b433b69e7d API: remove file and date transformations
We always deal with timestamps or base64 now. Removing some of the magic
makes everything less complex.

Only affected plugin is confmanager, which needs an update.
2024-01-07 13:41:19 +01:00
Andreas Gohr d3856637cf API: clean up error codes
Error codes are now extracted from API core and printed on the OpenAPI
overview page. This makes it easier to see what is in use.

Error messages have been cleaned up, some new codes have been assigned.

Some errors have been removed. Eg. it is fine to iterate a media
namespace you don't have read access to. The result will either be empty
or contain files from lower namespaces that you *do* have access to.
2024-01-07 13:41:19 +01:00
Andreas Gohr 902647e630 API: Do not assume the start page for empty pageIDs 2024-01-07 13:41:19 +01:00
Andreas Gohr 0e8fe8122f ensure api explorer stays english
See https://github.com/Authress-Engineering/openapi-explorer/issues/207
2024-01-07 13:41:19 +01:00
Andreas Gohr e4e3d43949 moved OpenAPI generator to correct namespace
added missing doc blocks
2024-01-07 13:41:19 +01:00
Andreas Gohr 0caa81c700 API: move create/delete user calls to usermanager
This only moves the calls. A proper refactoring of the user manager
would make sense:

1) introduce a helper component covering the basic operations including
   proper error signalling using Exceptions
2) refactor admin and cli components to make use of 1)
3) make the operations in 1) available via the API
2024-01-07 13:41:19 +01:00
Andreas Gohr f1cc602f77 OpenAPI Gen: fix requirement handling 2024-01-07 13:41:19 +01:00
Andreas Gohr 6cce3332fb Reworked API definition
This cleans up the API:

* no more compatibility with obsolete wiki API
* no more difference between wiki.* and dokuwiki.* calls -> core.*
* use of optional parameters avoids double definitions
* use Response objects for complex results
* always use named primitives as input
* major cleanup of docblock descriptions
2024-01-07 13:41:19 +01:00
Andreas Gohr dd7472d3f8 OpenAPI Gen: handle Object to Schema transformation correctly
All the basic mechanisms should now be in place to clean up the API
2024-01-07 13:41:19 +01:00
Andreas Gohr 53c2a557e0 OpenApi Gen: add toString method for easier testing 2024-01-07 13:41:19 +01:00
Andreas Gohr 8ddd9b6918 OpenAPI Generator. Better DocBlock parsing [WIP]
This introduces a new DocBlock parser to properly generate API
specifications. It also introduces the concept of Response classes to
better specify the response format.

This is still very much in progress.
2024-01-07 13:41:19 +01:00
Andreas Gohr fe9f11e2d0 improved API docs 2024-01-07 13:41:19 +01:00
Andreas Gohr 66f07661cd OpenAPI Gen: @link tag, examples for known params 2024-01-07 13:41:19 +01:00
Andreas Gohr 0ff4031c08 rename $id to be more clear
It should be more clear if a media or page ID is passed. Also
openapi-explorer will not prefill examples for any parameters called
*id*.
2024-01-07 13:41:19 +01:00
Andreas Gohr 0c6e917818 OpenAPI Explorer basically works 2024-01-07 13:41:19 +01:00
Andreas Gohr 8a9282a2e6 improve the doc blocks in ApiCore 2024-01-07 13:41:19 +01:00
Andreas Gohr b05603ab33 fix type parsing for more complex types 2024-01-07 13:41:19 +01:00
Andreas Gohr e7323dfb8c Do not directly use native function in API
As fedb877023 showed, we can not directly
use native fuctions because they have no proper type hinting in PHP7.4
2024-01-07 13:41:19 +01:00
Andreas Gohr d95846aa88 final set of API tests refactored 2024-01-07 13:41:19 +01:00
Andreas Gohr 535851891f another set of api tests 2024-01-07 13:41:19 +01:00
Andreas Gohr 1468a1289a Fix first set of API tests 2024-01-07 13:41:19 +01:00
Andreas Gohr 42e66c7a3a First go at refactoring the API mechanisms
This introduces an ApiCall class that wraps around the actual method
that produces the result. This replaces various loose array structures
that provided the meta information before.

The ApiCall streamlines the aggregation of meta information between core
and plugin methods. Now all data is produced by Reflection based
introspection. Certain aspects can be overridden if needed. See
ApiCore::getRemoteInfo() for examples

This change removes the _getMethods() method from remote plugins and
introduces a getMethods() method. The two are NOT compatible as the
latter now returns a list of ApiCalls. However when looking at the
existing plugins, it seems that _getMethods() was nearly 100% obsolete
with the Reflection based default implementation. So most plugins will
not be affected at all. Some might now export one or two more methods
than before because of poor visibility settings (eg. not declaring
private/protected methods as such).

This change removes the RPC_CALL_ADD hook. Only a single plugin ever
implemented it. I'm not sure what this hook was supposed to do anyway.
Being able to declare arbitrarily named API endpoints seems wrong to me
anyway.

The new ApiCall now also supports passing named instead of positional
parameters. This will open up a new opportunity to get a proper openapi
spec running.

Next step is fixing the tests.
2024-01-07 13:41:19 +01:00
Andreas Gohr 5ee967131b attempt to model the JSON-RPC API as openapi spec
Failed because positional parameters are not really possible to model.
Named parameter could be introduces when our minimum requirement is
switched to PHP8+
2024-01-07 13:41:19 +01:00
splitbrain 8a3002c918 🤖 Rector and PHPCS fixes 2023-11-29 15:10:52 +00:00
Andreas Gohr f0319d45ca
Merge pull request #4113 from dokuwiki/jsonrpc-conformity
JSONRPC Standards
2023-11-29 16:09:34 +01:00