From 09fcbbd0b9214718d2efabe9370cefc57bb80f9b Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Wed, 18 Nov 2026 17:15:06 +1100 Subject: [PATCH 1/2] fix(openapi): document Unix-second timestamps as integers --- OPENAPI_DOC.yml | 336 +++++++++++++++++++++---------------------- shard.lock | 6 +- shard.yml | 8 +- spec/openapi_spec.cr | 33 +++++ 4 files changed, 211 insertions(+), 172 deletions(-) create mode 100644 spec/openapi_spec.cr diff --git a/OPENAPI_DOC.yml b/OPENAPI_DOC.yml index 534d0d87..415cd132 100644 --- a/OPENAPI_DOC.yml +++ b/OPENAPI_DOC.yml @@ -45160,13 +45160,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45193,13 +45193,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45281,8 +45281,8 @@ components: format: Int64 expires_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" x_api_key: anyOf: @@ -45308,13 +45308,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45340,8 +45340,8 @@ components: - type: string expires_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" ttl: anyOf: @@ -45394,13 +45394,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45431,13 +45431,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" purchase_order_number: anyOf: @@ -45484,13 +45484,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45527,13 +45527,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" identifier: anyOf: @@ -45638,13 +45638,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45696,13 +45696,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45792,13 +45792,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -45873,13 +45873,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" auth_type: anyOf: @@ -45976,13 +45976,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" summary: anyOf: @@ -46077,13 +46077,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -46132,13 +46132,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -46217,13 +46217,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" modified_by_id: anyOf: @@ -46264,13 +46264,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" ip: anyOf: @@ -46340,8 +46340,8 @@ components: - type: "null" error_timestamp: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" launch_on_execute: anyOf: @@ -46399,13 +46399,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -46545,8 +46545,8 @@ components: - type: "null" signage_last_seen: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" playlist_item_id: anyOf: @@ -46635,13 +46635,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -46809,13 +46809,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -46835,8 +46835,8 @@ components: - type: string last_seen: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" online: anyOf: @@ -46864,11 +46864,11 @@ components: type: object properties: created_at: - type: string - format: date-time + type: integer + format: Int64 updated_at: - type: string - format: date-time + type: integer + format: Int64 name: type: string description: @@ -46877,8 +46877,8 @@ components: type: string last_seen: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" online: type: boolean @@ -47224,8 +47224,8 @@ components: - type: "null" created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" PlaceOS.Model.GroupInvitation: type: object @@ -47680,13 +47680,13 @@ components: - type: "null" created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" PlaceOS.Model.PendingMail: type: object @@ -47844,13 +47844,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48000,13 +48000,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48029,13 +48029,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48073,13 +48073,13 @@ components: - type: "null" valid_from: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" valid_until: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" authority_id: anyOf: @@ -48429,13 +48429,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48528,13 +48528,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48608,13 +48608,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" user_id: anyOf: @@ -48673,13 +48673,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" playlist_id: anyOf: @@ -48722,13 +48722,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -48970,13 +48970,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" storage_type: anyOf: @@ -49031,13 +49031,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" enabled: anyOf: @@ -49161,13 +49161,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" name: anyOf: @@ -49227,13 +49227,13 @@ components: properties: created_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" updated_at: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" uploaded_email: anyOf: @@ -49440,8 +49440,8 @@ components: type: object properties: created_at: - type: string - format: date-time + type: integer + format: Int64 name: type: string nickname: @@ -49524,8 +49524,8 @@ components: format: Int64 last_login: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" work_preferences: type: array @@ -49580,8 +49580,8 @@ components: type: object properties: created_at: - type: string - format: date-time + type: integer + format: Int64 name: type: string nickname: @@ -49664,8 +49664,8 @@ components: format: Int64 last_login: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" work_preferences: type: array @@ -49703,8 +49703,8 @@ components: type: object properties: created_at: - type: string - format: date-time + type: integer + format: Int64 name: type: string nickname: @@ -49767,8 +49767,8 @@ components: format: Int64 last_login: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" work_preferences: type: array @@ -49804,8 +49804,8 @@ components: type: object properties: created_at: - type: string - format: date-time + type: integer + format: Int64 name: type: string nickname: @@ -49868,8 +49868,8 @@ components: format: Int64 last_login: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" work_preferences: type: array @@ -50634,8 +50634,8 @@ components: - type: "null" time: anyOf: - - type: string - format: date-time + - type: integer + format: Int64 - type: "null" cron: anyOf: diff --git a/shard.lock b/shard.lock index 4d974d76..d270662d 100644 --- a/shard.lock +++ b/shard.lock @@ -11,7 +11,7 @@ shards: active-model: git: https://github.com/spider-gazelle/active-model.git - version: 4.7.1 + version: 4.7.2 ameba: git: https://github.com/crystal-ameba/ameba.git @@ -135,7 +135,7 @@ shards: json-schema: git: https://github.com/spider-gazelle/json-schema.git - version: 2.1.1 + version: 2.1.2 jwt: git: https://github.com/crystal-community/jwt.git @@ -223,7 +223,7 @@ shards: placeos-models: git: https://github.com/placeos/models.git - version: 9.123.5 + version: 9.123.6 placeos-resource: git: https://github.com/place-labs/resource.git diff --git a/shard.yml b/shard.yml index cbe7de95..934d2e2f 100644 --- a/shard.yml +++ b/shard.yml @@ -15,6 +15,12 @@ dependencies: # Data validation library active-model: github: spider-gazelle/active-model + version: ">= 4.7.2" + + # OpenAPI schema generation + json-schema: + github: spider-gazelle/json-schema + version: ">= 2.1.2" # Email validations CrystalEmail: @@ -58,7 +64,7 @@ dependencies: # Database view placeos-models: github: placeos/models - version: ">= 9.122" + version: ">= 9.123.6" # An abstraction over Fibers promise: diff --git a/spec/openapi_spec.cr b/spec/openapi_spec.cr new file mode 100644 index 00000000..3d391e30 --- /dev/null +++ b/spec/openapi_spec.cr @@ -0,0 +1,33 @@ +require "spec" +require "../src/config" + +describe "OpenAPI timestamp schemas" do + it "describes timestamps using their serialized types" do + refs = JSON::Schema::Definitions.new("#/components/schemas/") + + epoch = JSON.parse(%({"type":"integer","format":"Int64"})) + date_time = JSON.parse(%({"type":"string","format":"date-time"})) + null = JSON.parse(%({"type":"null"})) + + zone = JSON.parse(PlaceOS::Model::Zone.json_schema(refs: refs).to_json)["properties"] + zone["created_at"]["anyOf"].as_a.to_set.should eq Set{epoch, null} + zone["updated_at"]["anyOf"].as_a.to_set.should eq Set{epoch, null} + + api_key = JSON.parse(PlaceOS::Api::ApiKeys::Response.json_schema(refs: refs).to_json)["properties"] + api_key["created_at"].should eq epoch + api_key["expires_at"]["anyOf"].as_a.to_set.should eq Set{epoch, null} + + edge = JSON.parse(PlaceOS::Model::Edge::KeyResponse.json_schema(refs: refs).to_json)["properties"] + edge["created_at"].should eq epoch + edge["last_seen"]["anyOf"].as_a.to_set.should eq Set{epoch, null} + + shortener = JSON.parse(PlaceOS::Model::Shortener.json_schema(refs: refs).to_json)["properties"] + shortener["valid_from"]["anyOf"].as_a.to_set.should eq Set{epoch, null} + + group = JSON.parse(PlaceOS::Model::Group.json_schema(refs: refs).to_json)["properties"] + group["created_at"]["anyOf"].as_a.to_set.should eq Set{date_time, null} + + upload = JSON.parse(PlaceOS::Model::Upload.json_schema(refs: refs).to_json)["properties"] + upload["cache_modified"]["anyOf"].as_a.to_set.should eq Set{date_time, null} + end +end From cf776d75e20caa0433d2c1777ca95a84d832c226 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Wed, 18 Nov 2026 17:15:06 +1100 Subject: [PATCH 2/2] chore(shard.yml): bump version to 2.0.1 --- shard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.yml b/shard.yml index 934d2e2f..85a6034a 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: placeos-rest-api -version: 2.0.0 +version: 2.0.1 crystal: ">= 1.1.1" targets: