Table of Contents

Schema

Pure Farming supplies data which is formatted to align with schemas.
These schemas provide a blueprint for the data structure, defining the properties and constraints for data within that structure.

Tip

For more information on how JSON schema works, see the JSON schema specification at: json-schema.org.

Pure Farming uses schemas to:

  • Validate data to ensure it matches the expected structure and data types.
  • Ensure a consistent and predictable format for the data.
  • Document the data structure for consumers of the API.

As a result, Pure Farming makes use of existing schemas wherever possible. To date, we draw extensively from:

Where no schema exists for a particular data type, Pure Farming will create and publish schemas to document the data structure.
We publish our schemas on GitHub at: github.com/Pure-Farming/Schema.

Tip

See github.com/Pure-Farming/Schema for examples of the schemas we have published.

JSON Schema

Each of the schemas that we use has a discriminator. This is a property that identifies one schema/JSON from another.

In the case of Pure Farming, we use the resourceType property as the discriminator.
This is guaranteed to be present on all resources, and allows us to identify which schema applies to that resource.

For the list of what each of the resource types are see: Resource Types.

This means that you can always use the resourceType property determine what kind of object you are working with (at the root level).

For example, an icarAnimalCoreResource:

{
  "identifier": {
    "id": "id",
    "scheme": "scheme"
  },
  "alternativeIdentifiers": [
    {
      "id": "id",
      "scheme": "scheme"
    }
  ],
  "specie": "Buffalo",
  "gender": "Female",
  "birthDate": "2023-07-27T01:37:14.9197410+00:00",
  ...
  "resourceType": "icarAnimalCoreResource",
  ...
}

The discriminator as provided for an icarAnimalCoreResource is the same as it's name.
As you might surmise, the icarAnimalCoreResource comes from iCAR, and is in fact defined outside of Pure Farming. This is intentional, and part of our commitment to using existing schemas wherever possible.