question on steps to add classes to repository to support custom restapi calls

8 views
Skip to first unread message

Paul Senn

unread,
Sep 13, 2025, 12:30:43 PMSep 13
to OpenOLAT
Hi we have some custom restapi calls we have used in Olat which I am now trying to incorporate in to an Olat 15.5 installation.  The code resides in the olat source tree under olat/restapi/repository and the functions build without error, but I am thinking there is a step involving adding the filenames to a rest api context.  This could mean modifying an xml file which I thought I did in the past , but cannot find in the documentation or my own records the right way to do this, or if it is necessary.  It would be great if just building a war including the new classes in the right spot would work and a scanner would pick them up but perhaps there is another step?

Thank you!

Stéphane Rossé

unread,
Sep 15, 2025, 3:25:21 AMSep 15
to OpenOlat
Hi

We use Apache CXF now. You can add an additional endpoint as a Spring component with some annotations:

@Component will load the endpoint and makes it available
@Path("repo/courses") is needed to build the URL of the endpoint
@Tag is for documentation only

Than you have the standard Annotations for REST: @GET, @PUT, @POST... with additional @Path informations and @Produce. New is @ApiResponse and @Operation which are used for documentation.

You can see an example at: org.olat.restapi.repository.course.CoursesWebService

Best regards
Stéphane

Paul Senn

unread,
Sep 16, 2025, 8:49:42 AM (14 days ago) Sep 16
to open...@googlegroups.com
Thank you so much Stephanie, I see your authorship in this code so I know I am talking to the best possible expert!    So to make sure I have the picture,  I originally modeled the calls I created after  ..restapi/repository/RepositoryEntriesResource.   So if I create a file called HypRepositoryEntriesResourceWebServce, modeled after RepositoryEntriesWebService in that directory, containing my functions with the annotations , is anything more necessary?   Those functions already exist there in a file called HypRepositoryEntriesResource.java modeled after the old RepositoryEntriesResource.java.    In the old days, there was no file called RepositoryEntriesWebService, correct?   



--
--
Sie erhalten diese Nachricht, weil Sie Mitglied sind von Google
Groups-Gruppe "OpenOlat".
Für das Erstellen von Beiträgen in dieser Gruppe senden Sie eine E-Mail
an open...@googlegroups.com
Um sich von dieser Gruppe abzumelden, senden Sie eine E-Mail an
openolat+u...@googlegroups.com
Weitere Optionen finden Sie in dieser Gruppe unter
http://groups.google.com/group/openolat?hl=de
-------------------------------------------------------------------------------------------------------------------
OpenOlat - infinite learning - http://www.openolat.org
---
You received this message because you are subscribed to the Google Groups "OpenOlat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openolat+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/openolat/4dcf785f-4e9c-41e3-b65a-7f8d93c21015n%40googlegroups.com.
Message has been deleted

Stéphane Rossé

unread,
Sep 19, 2025, 1:19:56 AM (11 days ago) Sep 19
to OpenOlat
You can model your code after RepositoryEntriesWebService but without the @OpenAPIDefinition annotation. There must be only one unique @OpenAPIDefinition annotation in the code for the documentation.

Your web service will be discovered by the Spring framework. You have several XML configurations like restApiContext.xml with the line:

<context:component-scan base-package="org.olat.restapi,org.olat.restapi.security,org.olat.restapi.system" />

The package where your HypRepositoryEntriesResourceWebService stay need to be in one of the packages declared in these <context:component-scan>. For performance reasons, we don't have auto-discovery.

If you want that your HypRepositoryEntriesResourceWebService appears in the documentation, you need to add the package in the bean declaration:

<bean id="openApiFeature" class="org.apache.cxf.jaxrs.openapi.OpenApiFeature">

defined in restApiContext.xml (there is a list of packages here too).

Best regards
Stéphane
Reply all
Reply to author
Forward
0 new messages