Third Party Developer Blog

Jun
26

ESI and optional booleans

CCP SnowedIn | 2017-06-26 16:34

Greetings space developers,

Just wanted to send out a short update to notify everyone of a behavioral change in ESI. By the time you're reading this, ESI will have stopped sending optional boolean attributes when they are not True.

If a spec has the boolean as required, the value will always be sent. Otherwise the key/value will only be sent if the value is True.

An object property is required only if it is listed in the object schema's required array. For example, the alliance object in the GET /v1/corporations/{corporation_id}/alliancehistory/ 200 response array, each object has an alliance property, which is defined as:

{
  "description": "alliance object",
  "properties": {
    "alliance_id": {
      "description": "alliance_id integer",
      "format": "int32",
      "title": "get_corporations_corporation_id_alliancehistory_alliance_id",
      "type": "integer"
    },
    "is_deleted": {
      "description": "True if the alliance has been deleted",
      "title": "get_corporations_corporation_id_alliancehistory_is_deleted",
      "type": "boolean"
    }
  },
  "required": [
    "alliance_id",
    "is_deleted"
  ],
  "title": "get_corporations_corporation_id_alliancehistory_alliance",
  "type": "object"
}

By listing is_deleted in required ESI will return the is_deleted property regardless of its value. In contrast, the GET /v2/corporations/{corporation_id}/alliancehistory/ 200 response array is defined with:

{
  "description": "200 ok object",
  "properties": {
    "alliance_id": {
      "description": "alliance_id integer",
      "format": "int32",
      "title": "get_corporations_corporation_id_alliancehistory_alliance_id",
      "type": "integer"
    },
    "is_deleted": {
      "description": "True if the alliance has been closed",
      "title": "get_corporations_corporation_id_alliancehistory_is_deleted",
      "type": "boolean"
    },
    "record_id": {
      "description": "An incrementing ID that can be used to canonically establish order of records in cases where dates may be ambiguous",
      "format": "int32",
      "title": "get_corporations_corporation_id_alliancehistory_record_id",
      "type": "integer"
    },
    "start_date": {
      "description": "start_date string",
      "format": "date-time",
      "title": "get_corporations_corporation_id_alliancehistory_start_date",
      "type": "string"
    }
  },
  "required": [
    "start_date",
    "record_id"
  ],
  "title": "get_corporations_corporation_id_alliancehistory_200_ok",
  "type": "object"
}

The response has been flattened, what used to be a nested attribute is now part of the base object. However, is_deleted is not in the required array. Because of this, if the alliance is not deleted, the is_deleted parameter will not be included.

Depending on your language and the swagger client you are using, you may notice that you have to access parameters in a safer way (ie, use resp.get("some_key") instead of resp["some_key"] in python). This will be very implementation specific though, consult the documentation for your swagger client and/or language of choice.

-CCP SnowedIn

back