Generate a Client SDK
You can generate full-featured RESTful API clients with our OpenAPI Spec by using any third-party OpenAPI specification-compliant code generators, such as OpenAPI Generator (recommended). You only need to update the specification with our new or modified endpoints and quickly generate client SDK in various programming languages. This document provides an example of leveraging the openAPI generator to customize and streamline API development. You can also generate client SDKs using Swagger Codegen, Swagger Editor, and Swagger Hub as shown in subsequent sections.
Prerequisites
OpenAPI Generator
For steps to get started, refer to OpenAPI Generator.
JAR File
Note down the location of the openapi-generator-cli.jar
file.
Optum OpenAPI Spec
- Copy the URL for the required OpenAPI specification, for example, for the Professional Claims V3 Getting Started page.
- To copy the link (
https://developer.optum.com/eligibilityandclaims/openapi/60352a6f7e12f500829d5bbe
), right-click the Download OpenAPI Spec as highlighted in the preceding figure.
Optionally, you can download the OpenAPI Spec locally and view the specification by clicking the Download OpenAPI Spec button.
Generate a client SDK using the OpenAPI generator
This is a client SDK example in Java.
- Enter the location of the
openapi-generator-cli.jar
marked within the angle brackets in the following example and run the command at the command prompt.
java -jar <location of (openapi-generator-cli.jar)> generate \
-i https://developer.optum.com/eligibilityandclaims/openapi/627c2f20535bfe0014015fb9 \
-g java \
-o output
Parameter definitions
Parameter | Description |
---|---|
java -jar | JAR, as per this example, openapi-generator-cli.jar |
-i | Path to the OpenAPI Spec (copied as shown in section) |
-l | Desired language to generate the API code in |
-o | Output folder for the code to be generated |
- View the generated code in the output folder.
- Build your project using the generated Optum API code.
Optional ways to generate the client SDK
Generate a client SDK using Swagger Codegen
- Copy the Optum OpenAPI Spec.
- Get started with Swagger-Codegen.
- Run the following command at the command prompt (the following example uses
swagger-codegen-cli-3.0.35.jar
):
```
java -jar swagger-codegen-cli-3.0.35.jar generate /
-i https://developer.optum.com/eligibilityandclaims/openapi/60352a6f7e12f500829d5bbe /
-l java /
-o out
```
- View the generated code in the output folder.
- Build your project using the generated Optum API code.
Using Swagger Hub
- Follow the instructions to create an Swagger Hub account.
- Click Create New >> Create New API.
- Select these fields:
- Specification: OpenAPI 3.0.0
- Template: None
- Name: API name, for example, Medical_Client_SDK
- Version: For example, V1
- Open the downloaded Optum OpenAPI Spec in an editor of your choice and to copy all the content of the file.
- Paste the copied OpenAPI Spec content in the Swagger Hub editor window to paste the copied content to view the API output as shown here:
- On the top-right corner, click Export, and then select Client SDK as marked in the preceding figure.
This downloads the API code locally, which you can use to build your project.
Generate a client SDK using Swagger Editor
- Go to Swagger Editor.
- Click File >> Import File and select the downloaded Optum OpenAPI Spec.
The API output appears as shown here:
- Click Generate Client and select the language, for example, java as indicated in the preceding figure.
This downloads the API code locally, which you can use to build your project.
Related topics
- Try our APIs using our API collection in Postman or using our interactive documentation's Try It interface.
Updated 3 months ago