Key

This section outlines how to use code generation to create an Ed-Fi ODS / API Client SDK using a Windows environment targeting C#. The high-level steps are:

Table of Contents

include

Step \d+.*

Each step is outlined in detail below.

Step 1. Install Latest Version of Java

If you don't already have Java installed, navigate to https://java.com/en/download/ and download the latest installer. Run the installer to install the latest version of Java. In case you're wondering: the code generation leverages Java, but it does output C# code.

Step 2. Download the Swagger Codegen JAR File

Download the latest version of the Swagger Codegen JAR 2.3.0+. Windows users can use Invoke-WebRequest in PowerShell 3.0+.

When generating an SDK using the Swagger CodeGen resources in a language other than C# or Java and there are profiles defined in the OpenAPI specification file, be sure to verify that the proper contentTypes where created during the code generation.

Step 3. Generate the SDK Source Files

The SDK source files are generated via a few simple PowerShell commands.

To generate SDK source files, navigate to the folder containing swagger-codegen-cli.jar and run the following commands in PowerShell 3.0+ to generate C# SDK source files for the Ed-Fi-hosted instance at https://api.ed-fi.org/v3.2.0/api/.

Wait for the Swagger Codegen to finish generating code. A Visual Studio Solution named EdFi.OdsApi.Sdk.sln will be created with the SDK artifacts.

Build the project and run it without debugging (Ctrl+F5) and you should see the following results:

With that, you're done!

This exercise leveraged a publicly available instance of the API, which contains the surface for a core implementation. If you're working with a specific platform host, a great next step is to use these same techniques to generate an SDK for that platform. If the platform host has extended the data model, your new code will automatically include those structures in the data access components in the generated code.

Panel

borderColor

#fec43d

bgColor

#ffedc4

borderWidth

1

titleBGColor

#fec43d

borderStyle

solid

title

Downloads

The following link is a ZIP archive containing a C# sample program that uses the client SDK: