API Docs

API Docs
lac31
You can create client code (SDKs) to make RESTful data easy to consume in your application (for example, Java Plain Old Java Objects (POJOs) or .NET Plain Old CLR Objects (POCOs)) using Swagger-based tools. You can document your API using the Swagger service
CA Live API Creator
 includes. Besides API documentation, this service drives several tools in the Swagger ecosystem, such as generation of client SDKs.
For more information about Swagger, see the Swagger site.
In this article:
2
Access Swagger
You can access Swagger in API Creator from the following locations in API Creator:
On the
API Documentation
tab, Swagger starts by showing a list of APIs. These are your database objects (tables, views and stored procedures) and your custom resources. You can expand the list to list the operations. You can further expand the operations to see the JSON details, as shown in the following image of the API Documentation page:
The Swagger specification for your API is available at the URL specified in the URL box near the Swagger logo. You can use it, possibly with the API key on the URL, for example:
.../@docs?auth=MyApiKey:1
References for your API
A reference for your API is available from the 
Connecting
 tab. To view this tab, from the Execute section, click 
API Docs
. You can also access code samples by clicking the 
Code samples
 tab.
For example, RESTful calls require an authentication token. This requirement is shows in the following image of the Connecting tab:
Screen%20Shot%202016-06-22%20at%205.14.02%20PM.png
REST APIs
Swagger's popularity has resulted in a rich ecosystem of tools built around Swagger. For example, you can generate client-side SDKs for your API using swagger-codegen, which can generate client-side APIs for Java, C#, Scala, Clojure, Dart, Go, Objective-C, Perl, Python, PHP, Ruby, and more.
For example, you can use a swagger-codegen-generated API, in the following case, for Java:
AllCustomersApi allCusts = new AllCustomersApi();
      // Set up the API client (only needs to be done once)
ApiClient client = allCusts.getApiClient();
client.setBasePath("https://rest.acme.com/rest/default/demo/v1");
client.addDefaultHeader("Authorization", "CALiveAPICreator demo_full:1");
client.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"));
      // Get all the customers
List<AllCustomers> custs = allCusts.allCustomersGet(null, null, null, null, null, null,
               null, null, null, null, null, null, null, null, null, null);
for (AllCustomers cust : custs) {
System.out.println("Customer: " + cust.getName());
}
For more information:
Retrieve Swagger Documentation for your API
Your API includes endpoints for Swagger generation. You can retireve the Swagger documentation for your API or you can get details about a specific endpoint.
You can also retrieve a Swagger document about an API using the 
@docs
 RESTful endpoint.
For more information about how to use this system RESTful endpoint, see System REST Endpoints.
  1. With your API open, in the Execute section, click
    REST Lab
    .
  2. Complete the following and then send your request by clicking
    GET
    :
    1. Select
      Metadata
      as the endpoint on which you want to operate.
    2. Select 
      @docs
       as the metadata call.
    For example, to get the Swagger documentation for your API:
    http://localhost:8080/rest/default/demo/v1/@docs
The JSON response appears in the
Response
section of the page.
Call Swagger in a Browser
You can access the Swagger documentation directly from a browser.
Prerequisite:
 You have enabled access to Swagger documentation without authentication.
For more information about how to enable access to Swagger documentation without authentication, see API Properties.
 
Connect to your API
You can get the details on how to connect to your API, including examples, using the Swagger API doc in API Creator.
With your API open, in the Execute section, click the 
API Docs
 tab.
Get Code Samples
You can get help connecting and returning your REST APIs and view the sample code fragments.
  1. With your API open, in the Execute section, click 
    API Docs
    .
    The 
    Connecting
     tab displays by default.
  2. Click the 
    Code samples
     tab.