Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions draft/openapi/components/parameters/id.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ required: true
schema:
$ref: ../schemas/id.yaml
description: |
Public global object identifier.

Identifiers should be UUID v4.
Public global object identifier, see [_id URI representation](#id-uri-representation).

Once object is assigned a global identifier, it should never change.
Internally local identifiers, should be associated with public
Expand Down
37 changes: 33 additions & 4 deletions draft/openapi/components/schemas/id.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
type: string
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
examples:
- abdd1245-bbf9-4085-9366-f11c0f737c1d
oneOf:
- title: Integer
type: integer
description: Integer identifier
minimum: 1
examples:
- 123
- title: UUID
type: string
format: uuid
description: UUID identifier
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
examples:
- abdd1245-bbf9-4085-9366-f11c0f737c1d
- title: String
type: string
description: String identifier, prefixed with =
pattern: ^=[^\s]+$
examples:
- =some-name
- title: Composite
type: string
description: Composite string identifier
pattern: ^[^=\s][^\s]*$
examples:
- 42,LT
- title: Base32
type: string
format: base32
description: Base32 identifier, prefixed with =. See [Base32 identifier](#id-uri-representation).
pattern: ^=[A-Z2-7]+=*$
examples:
- =NBSWY3DP
111 changes: 107 additions & 4 deletions draft/openapi/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ All API URL's are constructed using one of the following patters:
<span class="green">dataset</span> `/`
<span class="green">model<span>

- Get single object:
- Get single object, see [_id URI representation](#id-uri-representation):

`https://`
<span class="green">domain</span> `/`
Expand Down Expand Up @@ -782,14 +782,111 @@ same building, but the global identifier must be the same for all datasets.
Global identifiers must be assigned to all objects using a reserved property
name `_id`.

For example we can have multiple datasets containing data abould the same
For example we can have multiple datasets containing data about the same
building, since building is the same, single global identifier must be used:

```text
/datasets/gov/rc/ar/uapi/text_with_coordinates/Address/e96cc0cc-08be-460d-a887-98f80612a402
/datasets/gov/rc/ntr/uapi/report/Pastatas/e96cc0cc-08be-460d-a887-98f80612a402
```

### Identifier formats

<a id="id-uri-representation"></a>

#### Integer identifier

Identifier can be stored as a plain integer in JSON and is used directly in the URI.

JSON:
```json
{"_id": 123}
```

URI:
```
Model/123
```

#### UUID identifier

Identifier can be stored as a UUID string in JSON and is used directly in the URI.

JSON:
```json
{"_id": "abdd1245-bbf9-4085-9366-f11c0f737c1d"}
```

URI:
```
Model/abdd1245-bbf9-4085-9366-f11c0f737c1d
```

#### String identifier

Identifier can be stored as a plain string in JSON. In the URI it is prefixed with `=` to distinguish it from model and property names.

JSON:
```json
{"_id": "some-name"}
```

URI:
```
Model/=some-name
```

#### Composite identifier

Identifier can be stored as a comma-separated string of multiple fields in JSON and is used directly in the URI.

JSON:
```json
{"_id": "42,LT"}
```

URI:
```
Model/42,LT
```

#### Base32 identifier

Identifier can be stored as a Base32-encoded string in JSON and is prefixed with `=` in the URI.

For a simple (non-composite) value, the raw value is Base32-encoded directly:

```
"hello" → NBSWY3DP
```

JSON:
```json
{"_id": "NBSWY3DP"}
```

URI:
```
Model/=NBSWY3DP
```

For a composite value, the fields are put into an array and encoded using CBOR encoding, then the result is Base32-encoded:

```
[42, "LT"] → CBOR → 82182a624c54 → Base32 → QIMCMJSGK3TF
```

JSON:
```json
{"_id": "QIMCMJSGK3TF"}
```

URI:
```
Model/=QIMCMJSGK3TF
```


## Model

Real world entities are identified using global identifiers. Each real world
Expand Down Expand Up @@ -964,8 +1061,14 @@ Version number is a singe positive integer number specifying major version of th
All objects must have a revision number provided as reserved `_revision`
property name.

Revision is a string, that identifies object version. This might be a UUID
string.
Revision can be defined in the manifest, using `_revision` as the property
name. `_revision` can be defined as one of these types:
- String
- Base32
- UUID
- Integer
- Composite
The formats follow the same rules, as `_id` formats, see [Identifier formats](#id-uri-representation).

When update action is made on an object, revision number must always be
provided, in order to compare object version received by the Client and object
Expand Down
Loading