# 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:

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-6a6d7ccbf6724174a5aa63ea1a309c07be51b946%2Frest_docs_1.png?alt=media" alt="Redocly"><figcaption></figcaption></figure></div>

### Swagger UI

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-5bffc9b33634a902e3e4ca936788781909db61c6%2Frest_docs_2.png?alt=media" alt="Swagger"><figcaption></figcaption></figure></div>

This will then generate the Open API Definition like below:

```yaml
{
  "openapi": "3.0.1",
  "info": {
    "title": "Web API",
    "version": "1"
  },
  "servers": [
    {
      "url": "http://localhost:8080/service"
    }
  ],
  "paths": {
    "/customers": {
      "get": {
        "operationId": "GetCustomers",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {}
}
```

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

* [RESTHost Overview Guide](https://docs.linx.software/guides/rest-overview)
* [Get Started - Hello World](https://community.linx.software/t/resthost-hello-world/466)
* [Before and After Operation Events](https://docs.linx.software/guides/rest_operation_events)
* [Working with inputs](https://docs.linx.software/guides/resthost-working-with-inputs)
* [Handling responses](https://docs.linx.software/guides/rest-responses)
* [Securing Your API](https://community.linx.software/t/resthost-guide-securing-your-api/462)
* [Generating API Documentation](https://docs.linx.software/guides/rest-documentation)
* [Sample Solution: CRUD and File Operations](https://community.linx.software/t/resthost-sample-solution-crud-and-file-operations/467)

***

## Sample

View our sample solution on GitHub: <https://github.com/linx-software/petstore-api>
