RESTHost -documentation generation
The SimpleRESTHost and RESTHost services include functionality that involves automatically generating the API documentation of the service.
To generate the documentation when the service is active, select the type of API documentation from the service Properties in the Linx Designer:
None: No documentation will be generated
Swagger: Documentation will be generated with Swagger UI
Redocly: Documentation will be generated with Redocly
Once the service is deployed and activated, navigate to: #base_uri#/swagger
or #base_uri#/redocly
For example, if my Base URI is configured to http://+:8022/service
and I'm hosting it on the cloud server http://test.linx.twenty57.net
, to access the API Documentation, I would navigate to: http://test.linx.twenty57.net:8022/service/swagger
This then allows external users to view the possibilities of the web service.
If you are still developing your web service, you are also able to generate the API documentation locally using service debugging by setting your Base URI to http://localhost:8080/service
.
To access the API Documentation locally, navigate to: http://localhost:8080/service/swagger
Generating an API Definition
You are also able to access the actual API definition of the web service which can then be used to:
Convert a SimpleRESTHost into a RESTHost by importing the Open API Definition as the API Definition property.
Import the definition into another Solution
Use the definition externally
To download the API definition, navigate to: http://localhost:8080/service/documentation/openapi.json
Alternatively, click on the relevant options:
Redocly:
Swagger UI
This will then generate the Open API Definition like below:
You can then copy this JSON structure out and import it as the API Definition of the RESTHost service.
Other guides for hosting a REST API
Sample
View our sample solution on GitHub: https://github.com/linx-software/petstore-api
Last updated