Skip to content

JSPWIKI-1310 Move the REST API to the module jspwiki-rest-api and write its JSON with Jackson - #650

Draft
arturobernalg wants to merge 29 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1310-rest-module
Draft

arturobernalg wants to merge 29 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1310-rest-module

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Part of JSPWIKI-1310. This pull request builds on #589, #590, #645 and #646, so it shows their commits until they are merged; the new commit is the last one.

It does the two changes that Juan Pablo asked for in #589:

  • The REST API is in its own Maven module, jspwiki-rest-api: the servlet, openapi.yaml and the tests moved from jspwiki-main without a change of package or class name, so the web.xml of the war is the same. The war, the BOM and the root pom list the new module. jspwiki-main does not depend on it.
  • The JSON is written with Jackson, which the wiki already uses, and not with Gson. The answers are records. A field without a value, such as the author of a page that has none, is left out, as before. One difference: Jackson does not escape characters such as equals signs or angle brackets as unicode escapes, as Gson did, which is still valid JSON for every client.

The tests moved too and read the answers with Jackson. They need the user and group databases of the tests of jspwiki-main, which they read from the file system, so the module has a copy of those two files in its test resources.

Checked: the 41 tests of the module pass, and a war built from this branch in Tomcat 10.1 answered the list of pages, a page, its history, attachments, references and HTML, a page with an ACL (401), an unknown page (404) and a bad offset (400). Not tried: the search in that war, whose index was not built yet (the tests cover it).

Not done, because it is a bigger change: Alex's idea to use the plugin system of WikiAjaxServlet.

…n OpenAPI file that a test compares with the answers
…o feature/JSPWIKI-1310-plugins-suggestions

# Conflicts:
#	ChangeLog.md
…310-plugins-suggestions

# Conflicts:
#	ChangeLog.md
…o feature/JSPWIKI-1310-plugins-suggestions

# Conflicts:
#	ChangeLog.md
#	jspwiki-main/src/main/java/org/apache/wiki/search/DefaultSearchManager.java
…gestions' into feature/JSPWIKI-1310-pages-read
… into feature/JSPWIKI-1310-pages-list

# Conflicts:
#	jspwiki-main/src/test/java/org/apache/wiki/rest/ApiV1ServletTest.java
…gestions' into feature/JSPWIKI-1310-pages-read
…gestions' into feature/JSPWIKI-1310-pages-read

# Conflicts:
#	ChangeLog.md
… into feature/JSPWIKI-1310-pages-list

# Conflicts:
#	ChangeLog.md
…d a description that broke the JAX-RS generator
@arturobernalg

Copy link
Copy Markdown
Member Author

Juan Pablo, about openapi-generator, which I said I would check: I ran openapi-generator 7.27.0 on openapi.yaml. It validates without warnings. The Java client (native library) compiles, and I used it against a running wiki (Tomcat with the war of this branch): listing pages, reading a page, its history, its html, references, attachments, the plugins and the search all return what the client expects, and a 404 arrives as an ApiException with the message. The generator for JAX-RS interfaces (jaxrs-spec) compiles too.

It showed two small problems in the description, fixed in the last commit of this pull request: a description with double quotes made the JAX-RS generator write code that does not compile, and without tags everything ended in one class, so the operations now have the tags Search, Plugins and Pages.

About the endorsed library: this API is a plain servlet and uses no JAX-RS, so I do not need it for now. If you had something else in mind for it, please tell me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant