Über generische OpenAPI Dokumente können verschiedene REST Client automatisiert erstellt werden, z. BThe OpenAPI document is a JSON document and describes the API formal. Using such generic OpenAPI documents various REST clients can be created automatically e.g. JavaScript, Java oder C#. Das OpenAPI Dokument ist ein JSON Dokument und beschreibt das API Formal.or C #.
OpenAPI Dokument
Um auf das OpenAPI Dokument der AMPAREX API zuzugreifen dient folgender LinkThe following link can be used to access the OpenAPI document of the AMPAREX API:
https://<host>/amparex/webaxapi/v2/api-docs
oder or
http://<host>:8080/amparex/webaxapi/v2/api-docs
Je nach Server muss <host> durch den Server (z. BDepending on the server, <host> must be replaced by the server name (e.g. preview1) ersetzt werden. Das Ergebnis ist ein JSON Dokument das aus dem Browser kopiert werden muss:
Hinweis |
---|
Bitte beachten Sie, dass der Zugriff auf das Open-API Dokument nur auf Testservern funktioniert. |
Dieses JSON Dokument ist die Beschreibung der AMPAREX API und kann z. B. für SwaggerHub verwendet werden.
SwaggerHub
Nun benötigt man noch das Swagger Tool 'Swagger-UI' um die API zu visualisieren. Dazu sind folgende Schritte nötig:
. The result is a JSON document that has to be copied from the browser:
Hinweis | ||
---|---|---|
| ||
Access to the Open API document only works on test servers. |
The below JSON document is a description of AMPAREX API for SwaggerHub.
SwaggerHub
In order to visualize the API one needs the Swagger tool, 'Swagger-UI'. The following steps are necessary to set it up:
Description | ||||||||
---|---|---|---|---|---|---|---|---|
01) Create an account under SwaggerHub 02) Log in to SwaggerHub 03) Create a new API | ||||||||
04) Fill out the dialogue as shown on the right 05) Click ‘Create New API’ 06) The Swagger UI will open with the OpenAPI editor. The editor is on the left and the API documentation is on the right | ||||||||
07) Now copy the previously copied OpenAPI JSON document from the | Beschreibung | |||||||
(01) Account unter SwaggerHub anlegen. (02) Bei SwaggerHub einloggen. (03) Neue API erstellen. | ||||||||
(04) Dialog wie nebenstehnd ausfüllen (05) Create API klicken. (06) Nun öffnet sich die Swagger-UI mit dem OpenAPI Editor. Im linken Teil befindet sich der Editor und im rechten Teil die Dokumentation der API. | ||||||||
(07) Nun das zuvor kopierte OpenAPI JSON Dokument von der URL 'http: //localhost: 8080/amparex/webaxapi/v2/api-docs' in das linke Editor Fenster kopieren. (08) Die Frage ob von JSON in XAML konvertiert werden soll, mit 'JA' bestätigen. | ||||||||
(09) Nun wird rechts in der Vorschau die API Dokumentation angezeigt. (10) Dieses Dokument ist die Dokumentation der API. Im oberen Teil befinden sich die einzelnen Zugriffsmethoden der API. Im unteren Teil ist das Model d. h. die Entitäten (z. B. Artikel) beschrieben. | ||||||||
(11) Im Kopfmenü von SwaggerHub gibt es eine Download Schaltfläche. Über diese kann einfach ein RestClient Projekt erstellt werden mit dem komfortabel die API verwendet werden kann. (12) Dort sind die verschiedensten Sprachen zu finden. In unserem Beispiel wird ein Java Client erstellt. | ||||||||
(13) Das erstellte Zip File wird gespeichert. (14) Das Projekt kann in einer Java Entwicklungsumgebung geöffnet werden. Am Besten erstellt man sich daraus ein JAR File. | ||||||||
into the left editor window 08) Confirm the question whether to convert from JSON to XAML with 'Yes' | ||||||||
09) The API documentation is now shown in the preview on the right. 10) This document is the API documentation. In the upper part you’ll find the individual access methods for the API. The lower part describes the ‘model’ which means the entities (e.g. article). | ||||||||
11) There is a download button in the SwaggerHub header menu. It can be used to easily create a RestClient project in order to use the API more conveniently 12) There are many different languages to be found. In our example, a Java client is created | ||||||||
13) The created zip file will be saved. 14) The project can be opened in a Java development environment. The best would be to create a JAR file from it. | ||||||||
15) A 'Test Main Class' shows the use of the Rest Java client(15) Eine 'Test Main Klasse' zeigt die Verwendung des Rest Java Clients
|
...