Using Swagger Code Generation

Use swagger-codegen to generate client code.

To get started, refer to the swagger-codegen GitHub.

Follow this process:

  1. Install Apache Maven.
  2. Download the swagger-codegen source code from the GitHub repository.
  3. From a command prompt at the root directory of the Swagger source code, run the command mvn package.
  4. Create a .bat file similar to the following example:
    java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i
    http://localhost/CherwellApi/swagger/docs/all -l csharp -o cherwell/client/csharp
  5. Place the .bat file in the same level as the Swagger code gen modules directory.
    Note: The example script creates output in a cherwell/client/csharp directory at the same level where the .bat file is placed.
  6. Add the generated code from the output directory to your project and reference it.
You can now call the generated Swagger code for CSM.

Sample Authenticated Request

var service = new ServiceApi(baseuri);
var tokenResponse = service.ServiceToken("password", clientid, "", username, password, "", "Internal");
var searchesApi = new SearchesApi(Baseuri);
searchesApi.DefaultHeader.Add("Authorization", "Bearer " + tokenResponse.AccessToken);
var searchItemResponse = searchesApi.SearchesGetSearchItemsV1(null);
© Copyright 2018 Cherwell Software, LLC. All rights reserved.