Skip to main content

Changes in Example Values in Code Samples

· 3 min read

APIMatic SDKs have improved efficiency of internal processes in code sample generation. After this change, generated code samples may slightly change when SDKs are regenerated but there is no functional impact of this change.


Every time SDK is generated through APIMatic CodeGen, code samples are generated along with the client code. This code contains sample values that are generated with the client library. As a result of improving efficiency of internal processes, there is a change in these sample values.

How Code Sample Values are Generated

There are two ways through which sample values in code samples are generated:

  1. Using pre-existing examples from the API spec file.
  2. In case there are no existing examples in the spec file, SDK autogenerates dummy values.

In case of former, there will be no change in the code samples. But in latter, you might notice a few changes in the generated code samples.

Behavior of Dummy Values Before the Change

Before, when there were no specified value examples in the API spec, SDKs autogenerated idempotent dummy values. "Idempotent" values mean that you got the same values for the same API specification, no matter how many times you generated the SDK.

What Has Changed?

Now, when you generate an SDK, dummy values in the code samples may change. This is a one-time change that depends on changes in parameter or schema details, but the values remain valid. Similarly, when generating values for arrays and maps, the number of elements might also change.

Impact of this change

Let's take the following code sample for example:

var someObject = new SomeObjectClass.Builder()

In this code, string_value5 is a dummy value that the APIMatic CodeGen generated every time the SDK was generated. This value remained constant. After this new change, when you generate an SDK, you might see a change in this value. This becomes the new constant for this particular API specification.

var someObject = new SomeObjectClass.Builder()

In case of an array, there can be a variation in the number of elements. For example, if before this change, your SDK generated the following elements in an array:

var employees = new List<Employee>();

var employee0 = new Employee();
employee0.Address = "address0";
employee0.Age = 82L;

Now, the same array could have the following elements:

var employees = new List<Employee>();

var employee0 = new Employee();
employee0.Address = "address2";
employee0.Age = 254L;

var employee1 = new Employee();
employee1.Address = "address3";
employee1.Age = 255L;

Other Changes

There may be other non-functional changes in the code samples. These include:

  • Variation in lengths of maps
  • Changes in values of native types
  • Order of properties in an object's example value
  • Some fields may also be removed from the endpoint calls in the code samples because they were defined as readOnly in the API specification file

This change is noticeable in code samples of all languages.