From e860380a6322535be92d29c30adc726d4db890c6 Mon Sep 17 00:00:00 2001 From: Wannes Gennar Date: Wed, 6 Mar 2024 23:45:35 +0100 Subject: [PATCH] add type information to array schemas see #10 --- lib/helldivers_2_web/schemas/planet_schema.ex | 1 + lib/helldivers_2_web/schemas/war_info_schema.ex | 17 ++++++++++++++--- .../schemas/war_status_schema.ex | 8 +++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/helldivers_2_web/schemas/planet_schema.ex b/lib/helldivers_2_web/schemas/planet_schema.ex index b2eff3f..68c8d71 100644 --- a/lib/helldivers_2_web/schemas/planet_schema.ex +++ b/lib/helldivers_2_web/schemas/planet_schema.ex @@ -36,6 +36,7 @@ defmodule Helldivers2Web.Schemas.PlanetSchema do }, waypoints: %Schema{ type: :array, + items: %Schema{type: :integer}, description: "Waypoints, seems to link planets together but purpose unclear" }, max_health: %Schema{ diff --git a/lib/helldivers_2_web/schemas/war_info_schema.ex b/lib/helldivers_2_web/schemas/war_info_schema.ex index 390fb77..c6e7e70 100644 --- a/lib/helldivers_2_web/schemas/war_info_schema.ex +++ b/lib/helldivers_2_web/schemas/war_info_schema.ex @@ -5,7 +5,10 @@ defmodule Helldivers2Web.Schemas.WarInfoSchema do alias Helldivers2Web.Schemas.{PlanetSchema, HomeWorldSchema} @doc "Generates a schema for a single war info schema response" - def response(), do: {"War info response", "application/json", __MODULE__, Helldivers2Web.ApiSpec.default_options()} + def response(), + do: + {"War info response", "application/json", __MODULE__, + Helldivers2Web.ApiSpec.default_options()} OpenApiSpex.schema(%{ description: "Global overview of the war, it's planets, capitals etc", @@ -40,8 +43,16 @@ defmodule Helldivers2Web.Schemas.WarInfoSchema do items: HomeWorldSchema, description: "All homeworlds present in this war season" }, - capitals: %Schema{type: :array, description: "Empty, not been mapped yet"}, - planet_permanent_effects: %Schema{type: :array, description: "Empty, not been mapped yet"} + capitals: %Schema{ + type: :array, + items: %Schema{type: :integer}, + description: "Empty, not been mapped yet" + }, + planet_permanent_effects: %Schema{ + type: :array, + items: %Schema{type: :integer}, + description: "Empty, not been mapped yet" + } } }) end diff --git a/lib/helldivers_2_web/schemas/war_status_schema.ex b/lib/helldivers_2_web/schemas/war_status_schema.ex index 8302652..66acada 100644 --- a/lib/helldivers_2_web/schemas/war_status_schema.ex +++ b/lib/helldivers_2_web/schemas/war_status_schema.ex @@ -10,7 +10,10 @@ defmodule Helldivers2Web.Schemas.WarStatusSchema do alias OpenApiSpex.Schema @doc "Generates a schema for a single war info schema response" - def response(), do: {"War status response", "application/json", __MODULE__, Helldivers2Web.ApiSpec.default_options()} + def response(), + do: + {"War status response", "application/json", __MODULE__, + Helldivers2Web.ApiSpec.default_options()} OpenApiSpex.schema(%{ description: "Current status of the Helldivers offensive in the galactic war", @@ -50,16 +53,19 @@ defmodule Helldivers2Web.Schemas.WarStatusSchema do }, community_targets: %Schema{ type: :array, + items: %Schema{type: :integer}, description: "Always empty AFAIK, haven't figured this out" }, joint_operations: %Schema{type: :array, items: JointOperationSchema}, planet_events: %Schema{type: :array, items: PlanetEventSchema}, planet_active_effects: %Schema{ type: :array, + items: %Schema{type: :integer}, description: "Always empty AFAIK, haven't figured this out" }, active_election_policy_effects: %Schema{ type: :array, + items: %Schema{type: :integer}, description: "Always empty AFAIK, haven't figured this out" }, global_events: %Schema{type: :array, items: GlobalEventSchema}