# Models

## The BaseUnit object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"BaseUnit":{"type":"object","properties":{"code":{"type":"string","description":"The unit code."},"name":{"description":"The name of the unit in the form of a map (language, value) or string.","oneOf":[{"type":"string"},{"type":"object","additionalProperties":{"type":"string"}}]},"type":{"type":"string","description":"The type of a unit."},"symbol":{"type":"string","description":"The symbol of a unit."},"baseUnit":{"type":"boolean","description":"The base unit flag."},"factor":{"type":"number","description":"The conversion factor. The factor value must be greater than zero."}},"required":["code","name","type","baseUnit","factor"]}}}}
```

## The Unit object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"Unit":{"allOf":[{"$ref":"#/components/schemas/BaseUnit"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/UnitMetadata"}}}]},"BaseUnit":{"type":"object","properties":{"code":{"type":"string","description":"The unit code."},"name":{"description":"The name of the unit in the form of a map (language, value) or string.","oneOf":[{"type":"string"},{"type":"object","additionalProperties":{"type":"string"}}]},"type":{"type":"string","description":"The type of a unit."},"symbol":{"type":"string","description":"The symbol of a unit."},"baseUnit":{"type":"boolean","description":"The base unit flag."},"factor":{"type":"number","description":"The conversion factor. The factor value must be greater than zero."}},"required":["code","name","type","baseUnit","factor"]},"UnitMetadata":{"description":"The metadata of the unit.","properties":{"version":{"type":"integer","description":"The version of the document."},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of the unit creation compliant with the ISO 8601 standard."},"modifiedAt":{"type":"string","format":"date-time","description":"Timestamp of the unit last modification compliant with the ISO 8601 standard."}}}}}}
```

## The UpdateUnit object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"UpdateUnit":{"allOf":[{"$ref":"#/components/schemas/BaseUnit"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/UpdateUnitMetadata"}}}]},"BaseUnit":{"type":"object","properties":{"code":{"type":"string","description":"The unit code."},"name":{"description":"The name of the unit in the form of a map (language, value) or string.","oneOf":[{"type":"string"},{"type":"object","additionalProperties":{"type":"string"}}]},"type":{"type":"string","description":"The type of a unit."},"symbol":{"type":"string","description":"The symbol of a unit."},"baseUnit":{"type":"boolean","description":"The base unit flag."},"factor":{"type":"number","description":"The conversion factor. The factor value must be greater than zero."}},"required":["code","name","type","baseUnit","factor"]},"UpdateUnitMetadata":{"description":"The metadata of the unit.","properties":{"version":{"type":"integer","description":"The version of the document."}}}}}}
```

## The UnitMetadata object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"UnitMetadata":{"description":"The metadata of the unit.","properties":{"version":{"type":"integer","description":"The version of the document."},"createdAt":{"type":"string","format":"date-time","description":"Timestamp of the unit creation compliant with the ISO 8601 standard."},"modifiedAt":{"type":"string","format":"date-time","description":"Timestamp of the unit last modification compliant with the ISO 8601 standard."}}}}}}
```

## The UpdateUnitMetadata object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"UpdateUnitMetadata":{"description":"The metadata of the unit.","properties":{"version":{"type":"integer","description":"The version of the document."}}}}}}
```

## The ConversionFactorInput object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionFactorInput":{"description":"The input is the conversion parameters object containing the source unit code, target unit code, and the amount to convert (amount required for convert-unit, optional for conversion-factor).","type":"object","properties":{"sourceUnitAmount":{"type":"number"},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]}}}}
```

## The ConversionInput object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionInput":{"description":"The input payload for conversion. Contains the source unit code, target unit code, and optionally the source unit amount to convert.","type":"object","properties":{"sourceUnitAmount":{"type":"number","description":"The source unit quantity."},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]}}}}
```

## The ConversionFactorOutput object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionFactorOutput":{"description":"Output payload","properties":{"conversionFactor":{"type":"number","description":"The conversion factor."}}}}}}
```

## The ConversionOutput object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionOutput":{"description":"Output payload. Contains the computed result of a conversion factor - conversionFactor (number) and unit conversion - targetUnitAmount (number) and targetUnit (string).","properties":{"targetUnitAmount":{"type":"number","description":"The amount in the target unit after conversion from the source unit."},"targetUnit":{"type":"string","description":"The target unit."}}}}}}
```

## The ConversionFactorPayload object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionFactorPayload":{"type":"object","properties":{"commandUuid":{"description":"Optional client-generated identifier used to correlate a conversion command across request, response, and logs.","type":"string"},"input":{"$ref":"#/components/schemas/ConversionFactorInput"}},"required":["input"]},"ConversionFactorInput":{"description":"The input is the conversion parameters object containing the source unit code, target unit code, and the amount to convert (amount required for convert-unit, optional for conversion-factor).","type":"object","properties":{"sourceUnitAmount":{"type":"number"},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]}}}}
```

## The ConversionFactorResponse object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionFactorResponse":{"type":"object","properties":{"commandUuid":{"type":"string"},"input":{"$ref":"#/components/schemas/ConversionFactorInput"},"output":{"$ref":"#/components/schemas/ConversionFactorOutput"}}},"ConversionFactorInput":{"description":"The input is the conversion parameters object containing the source unit code, target unit code, and the amount to convert (amount required for convert-unit, optional for conversion-factor).","type":"object","properties":{"sourceUnitAmount":{"type":"number"},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]},"ConversionFactorOutput":{"description":"Output payload","properties":{"conversionFactor":{"type":"number","description":"The conversion factor."}}}}}}
```

## The ConversionPayload object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionPayload":{"type":"object","properties":{"commandUuid":{"type":"string"},"input":{"$ref":"#/components/schemas/ConversionInput"}},"required":["input"]},"ConversionInput":{"description":"The input payload for conversion. Contains the source unit code, target unit code, and optionally the source unit amount to convert.","type":"object","properties":{"sourceUnitAmount":{"type":"number","description":"The source unit quantity."},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]}}}}
```

## The ConversionResponse object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"ConversionResponse":{"type":"object","properties":{"commandUuid":{"type":"string"},"input":{"$ref":"#/components/schemas/ConversionInput"},"output":{"$ref":"#/components/schemas/ConversionOutput"}}},"ConversionInput":{"description":"The input payload for conversion. Contains the source unit code, target unit code, and optionally the source unit amount to convert.","type":"object","properties":{"sourceUnitAmount":{"type":"number","description":"The source unit quantity."},"sourceUnit":{"type":"string","description":"The source unit code."},"targetUnit":{"type":"string","description":"The target unit code."}},"required":["sourceUnit","targetUnit"]},"ConversionOutput":{"description":"Output payload. Contains the computed result of a conversion factor - conversionFactor (number) and unit conversion - targetUnitAmount (number) and targetUnit (string).","properties":{"targetUnitAmount":{"type":"number","description":"The amount in the target unit after conversion from the source unit."},"targetUnit":{"type":"string","description":"The target unit."}}}}}}
```

## The BadRequest400 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"BadRequest400":{"properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status Description."},"message":{"type":"string","description":"Error message."},"details":{"type":"array","description":"Error message details.","items":{"type":"string"}}}}}}}
```

## The BadRequestNoBody400 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"BadRequestNoBody400":{"properties":{"message":{"type":"string","description":"HTTP Status Description."},"_links":{"type":"object","properties":{"self":{"type":"object","properties":{"href":{"type":"string","description":"Link to the requested resource."},"templated":{"type":"boolean","description":"Link template flag."}}}}},"_embedded":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"Description of the error."},"path":{"type":"string","description":"Path associated with the error"}}}}}}}}}}}
```

## The BadConversionRequest400 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"BadConversionRequest400":{"properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status Description."},"message":{"type":"string","description":"Error message."}}}}}}
```

## The Conflict409 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"Conflict409":{"properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status Description."},"message":{"type":"string","description":"Error message."}}}}}}
```

## The Unauthorized401 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"Unauthorized401":{"properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}}
```

## The Forbidden403 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"Forbidden403":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status Description."},"message":{"type":"string","description":"Error message."}}}}}}
```

## The NotFound404 object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"NotFound404":{"properties":{"unitCode":{"type":"string","description":"The code of the requested unit."},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Detailed error message."}}}}}}
```

## The UnexpectedError object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"UnexpectedError":{"properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Detailed error message"}}}}}}
```

## The CreateUnitResponse object

```json
{"openapi":"3.0.0","info":{"title":"Unit Handling Service","version":"0.0.1"},"components":{"schemas":{"CreateUnitResponse":{"type":"object","properties":{"code":{"type":"string"}}}}}}
```
