{
  "swagger": "2.0",
  "info": {
    "title": "Units service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/units/v1/units": {
      "get": {
        "operationId": "UnitsService_getAllUnits",
        "summary": "Get all units",
        "tags": [
          "Units Service"
        ],
        "description": "Returns all known units, grouped by the physical property they measure.",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetUnitsResponse"
            },
            "x-example": {
              "unitsByProperty": {
                "<key>": [
                  {
                    "name": "<unit name>",
                    "symbol": "<unit symbol>",
                    "property": "<unit property>",
                    "dimension": {
                      "baseDimensions": {
                        "<key>": 1
                      }
                    },
                    "system": "<unit system>"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/units/v1/units/get-unit": {
      "post": {
        "operationId": "UnitsService_getUnit",
        "summary": "Get unit",
        "tags": [
          "Units Service"
        ],
        "description": "Returns information for a unit symbol if available. Returns as empty if the provided symbol cannot be parsed.",
        "parameters": [
          {
            "name": "unit",
            "in": "body",
            "schema": {
              "type": "string",
              "x-alias": "UnitSymbol",
              "example": "<unit symbol>"
            },
            "required": true,
            "x-example": "<unit symbol>"
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Unit"
            },
            "x-example": {
              "name": "<unit name>",
              "symbol": "<unit symbol>",
              "property": "<unit property>",
              "dimension": {
                "baseDimensions": {
                  "<key>": 1
                }
              },
              "system": "<unit system>"
            }
          },
          "204": {
            "description": "No content, when there is nothing to return."
          }
        }
      }
    },
    "/units/v1/units/get-batch-units": {
      "post": {
        "operationId": "UnitsService_getBatchUnits",
        "summary": "Get batch units",
        "tags": [
          "Units Service"
        ],
        "description": "Returns information for the unit symbols if available. If the provided symbol cannot be parsed, it will be omitted from the map.",
        "parameters": [
          {
            "name": "units",
            "in": "body",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "x-alias": "UnitSymbol"
              },
              "uniqueItems": true,
              "example": [
                "<unit symbol>"
              ]
            },
            "required": false,
            "x-example": [
              "<unit symbol>"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/Unit"
              },
              "x-map-key": "UnitSymbol"
            },
            "x-example": {
              "<key>": {
                "name": "<unit name>",
                "symbol": "<unit symbol>",
                "property": "<unit property>",
                "dimension": {
                  "baseDimensions": {
                    "<key>": 1
                  }
                },
                "system": "<unit system>"
              }
            }
          }
        }
      }
    },
    "/units/v1/units/commensurable-units": {
      "post": {
        "operationId": "UnitsService_getCommensurableUnits",
        "summary": "Get commensurable units",
        "tags": [
          "Units Service"
        ],
        "description": "Returns the set of cataloged units that can be converted to and from the given unit. No commensurable units does not imply the unit is invalid. Use /get-unit to check for validity.",
        "parameters": [
          {
            "name": "unit",
            "in": "body",
            "schema": {
              "type": "string",
              "x-alias": "UnitSymbol",
              "example": "<unit symbol>"
            },
            "required": true,
            "x-example": "<unit symbol>"
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Unit"
              },
              "uniqueItems": true
            },
            "x-example": [
              {
                "name": "<unit name>",
                "symbol": "<unit symbol>",
                "property": "<unit property>",
                "dimension": {
                  "baseDimensions": {
                    "<key>": 1
                  }
                },
                "system": "<unit system>"
              }
            ]
          }
        }
      }
    }
  },
  "definitions": {
    "GetUnitsResponse": {
      "type": "object",
      "properties": {
        "unitsByProperty": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/Unit"
            },
            "uniqueItems": true
          },
          "x-map-key": "UnitProperty"
        }
      }
    },
    "Unit": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "x-alias": "UnitName"
        },
        "symbol": {
          "type": "string",
          "x-alias": "UnitSymbol"
        },
        "property": {
          "type": "string",
          "x-alias": "UnitProperty",
          "description": "Empty if no property is available. If two units measure different properties, it is not possible to convert between them."
        },
        "dimension": {
          "allOf": [
            {
              "$ref": "#/definitions/UnitDimension"
            }
          ],
          "description": "The physical dimensions in terms of the base units of the system. It is only possible to convert units if they have the same dimension. Empty if the unit is a base unit."
        },
        "system": {
          "type": "string",
          "x-alias": "UnitSystem"
        }
      },
      "required": [
        "symbol",
        "system"
      ]
    },
    "UnitDimension": {
      "description": "The fundamental base dimensions and their exponents, whose product compose a unit.",
      "type": "object",
      "properties": {
        "baseDimensions": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Units Service",
      "x-displayName": "Units service",
      "description": "The Units Service serves as a comprehensive catalog of the units of measurement supported by Nominal. Units, by default, follow the UCUM convention for representation."
    }
  ]
}
