Skip to content

Commit

Permalink
Polish schema imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku committed May 12, 2022
1 parent 1a45cde commit f372b79
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
10 changes: 6 additions & 4 deletions lib/trento_web/openapi/schema/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule TrentoWeb.OpenApi.Schema.Cluster do
require OpenApiSpex
alias OpenApiSpex.Schema

alias TrentoWeb.OpenApi.Schema.{Checks, Provider, Tag}

defmodule ClusterResource do
@moduledoc false

Expand Down Expand Up @@ -121,7 +123,7 @@ defmodule TrentoWeb.OpenApi.Schema.Cluster do
id: %Schema{type: :integer, description: "Cluster ID"},
name: %Schema{type: :string, description: "Cluster name"},
sid: %Schema{type: :string, description: "SID"},
provider: TrentoWeb.OpenApi.Schema.Provider.SupportedProviders,
provider: Provider.SupportedProviders,
type: %Schema{
type: :string,
description: "Detected type of the cluster",
Expand Down Expand Up @@ -150,19 +152,19 @@ defmodule TrentoWeb.OpenApi.Schema.Cluster do
title: "HostChecksExecutions",
description: "A list of tags attached to a resource",
type: :array,
items: TrentoWeb.OpenApi.Schema.Checks.HostChecksExecution
items: Checks.HostChecksExecution
},
checks_results: %Schema{
title: "CheckResults",
description: "A list of tags attached to a resource",
type: :array,
items: TrentoWeb.OpenApi.Schema.Checks.CheckResult
items: Checks.CheckResult
},
tags: %Schema{
title: "Tags",
description: "A list of tags attached to a resource",
type: :array,
items: TrentoWeb.OpenApi.Schema.Tag
items: Tag
}
}
})
Expand Down
12 changes: 7 additions & 5 deletions lib/trento_web/openapi/schema/host.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule TrentoWeb.OpenApi.Schema.Host do
require OpenApiSpex
alias OpenApiSpex.Schema

alias TrentoWeb.OpenApi.Schema.{Provider, SlesSubscription, Tag}

defmodule IPv4 do
@moduledoc false

Expand Down Expand Up @@ -45,7 +47,7 @@ defmodule TrentoWeb.OpenApi.Schema.Host do
]
}
},
ssh_address: TrentoWeb.OpenApi.Schema.Host.IPv4,
ssh_address: IPv4,
agent_version: %Schema{
type: :string,
description: "Version of the agent installed on the host"
Expand All @@ -60,19 +62,19 @@ defmodule TrentoWeb.OpenApi.Schema.Host do
description: "Host's last heartbeat status",
enum: [:critical, :passing, :unknown]
},
provider: TrentoWeb.OpenApi.Schema.Provider.SupportedProviders,
provider_data: TrentoWeb.OpenApi.Schema.Provider.ProviderData,
provider: Provider.SupportedProviders,
provider_data: Provider.ProviderData,
tags: %Schema{
title: "Tags",
description: "A list of tags attached to a resource",
type: :array,
items: TrentoWeb.OpenApi.Schema.Tag
items: Tag
},
sles_subscriptions: %Schema{
title: "SlesSubscriptions",
description: "A list of the available SLES Subscriptions on a host",
type: :array,
items: TrentoWeb.OpenApi.Schema.SlesSubscription
items: SlesSubscription
}
}
})
Expand Down
24 changes: 12 additions & 12 deletions lib/trento_web/openapi/schema/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ defmodule TrentoWeb.OpenApi.Schema.Provider do
})
end

defmodule ProviderData do
@moduledoc false

OpenApiSpex.schema(%{
title: "ProviderMetadata",
description: "Detected metadata for any provider",
oneOf: [
TrentoWeb.OpenApi.Schema.Provider.AzureProviderData
]
})
end

defmodule AzureProviderData do
@moduledoc false

Expand All @@ -45,4 +33,16 @@ defmodule TrentoWeb.OpenApi.Schema.Provider do
}
})
end

defmodule ProviderData do
@moduledoc false

OpenApiSpex.schema(%{
title: "ProviderMetadata",
description: "Detected metadata for any provider",
oneOf: [
AzureProviderData
]
})
end
end

0 comments on commit f372b79

Please sign in to comment.