-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9dc09b1
commit d6c9826
Showing
13 changed files
with
266 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule PlexusWeb.ApiSpec do | ||
@behaviour OpenApiSpex.OpenApi | ||
|
||
@impl OpenApiSpex.OpenApi | ||
def spec do | ||
OpenApiSpex.resolve_schema_modules(%OpenApiSpex.OpenApi{ | ||
servers: [ | ||
OpenApiSpex.Server.from_endpoint(PlexusWeb.Endpoint) | ||
], | ||
info: %OpenApiSpex.Info{ | ||
title: "Plexus", | ||
version: to_string(Application.spec(:plexus, :vsn)) | ||
}, | ||
paths: OpenApiSpex.Paths.from_router(PlexusWeb.Router) | ||
}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.App do | ||
alias OpenApiSpex.Schema | ||
alias PlexusWeb.API.V1.Schemas.Scores | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "App", | ||
description: "A Representation of an App", | ||
type: :object, | ||
properties: %{ | ||
name: %Schema{type: :string, description: "Name"}, | ||
package: %Schema{type: :string, description: "Android Package"}, | ||
icon_url: %Schema{type: :string, description: "URL of Icon"}, | ||
scores: Scores | ||
}, | ||
example: %{ | ||
"name" => "YouTube Music", | ||
"package" => "com.google.android.youtube.tvmusic", | ||
"scores" => %{ | ||
"native" => %{ | ||
"rating_type" => "native", | ||
"numerator" => 1.2, | ||
"total_count" => 21, | ||
"denominator" => 4 | ||
}, | ||
"micro_g" => %{ | ||
"rating_type" => "micro_g", | ||
"numerator" => 4.0, | ||
"total_count" => 44, | ||
"denominator" => 4 | ||
} | ||
}, | ||
"icon_url" => | ||
"https://play-lh.googleusercontent.com/76AjYITcB0dI0sFqdQjNgXQxRMlDIswbp0BAU_O5Oob-73b6cqKggVlAiNXQAW5Bl1g" | ||
} | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.AppResponse do | ||
alias PlexusWeb.API.V1.Schemas.App | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "AppResponse", | ||
description: "Response schema for an application", | ||
type: :object, | ||
properties: %{ | ||
data: App | ||
}, | ||
example: %{ | ||
"data" => [ | ||
%{ | ||
"name" => "YouTube Music", | ||
"package" => "com.google.android.youtube.tvmusic", | ||
"scores" => %{ | ||
"native" => %{ | ||
"rating_type" => "native", | ||
"numerator" => 1.2, | ||
"total_count" => 21, | ||
"denominator" => 4 | ||
}, | ||
"micro_g" => %{ | ||
"rating_type" => "micro_g", | ||
"numerator" => 3.9, | ||
"total_count" => 44, | ||
"denominator" => 4 | ||
} | ||
}, | ||
"icon_url" => | ||
"https://play-lh.googleusercontent.com/lMoItBgdPPVDJsNOVtP26EKHePkwBg-PkuY9NOrc-fumRtTFP4XhpUNk_22syN4Datc" | ||
} | ||
] | ||
} | ||
}) | ||
end |
46 changes: 46 additions & 0 deletions
46
lib/plexus_web/controllers/api/v1/schemas/apps_response.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.AppsResponse do | ||
alias OpenApiSpex.Schema | ||
alias PlexusWeb.API.V1.Schemas.App | ||
alias PlexusWeb.API.V1.Schemas.Page | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "AppsResponse", | ||
description: "Response schema for a list of applications", | ||
type: :object, | ||
properties: %{ | ||
data: %Schema{type: :array, items: App}, | ||
meta: Page | ||
}, | ||
example: %{ | ||
"data" => [ | ||
%{ | ||
"name" => "YouTube Music", | ||
"package" => "com.google.android.youtube.tvmusic", | ||
"scores" => %{ | ||
"native" => %{ | ||
"rating_type" => "native", | ||
"numerator" => 1.1, | ||
"total_count" => 21, | ||
"denominator" => 4 | ||
}, | ||
"micro_g" => %{ | ||
"rating_type" => "micro_g", | ||
"numerator" => 3.7, | ||
"total_count" => 43, | ||
"denominator" => 4 | ||
} | ||
}, | ||
"icon_url" => | ||
"https://play-lh.googleusercontent.com/76AjYITcB0dI0sFqdQjNgXQxRMlDIswbp0BAU_O5Oob-73b6cqKggVlAiNXQAW5Bl1g" | ||
} | ||
], | ||
"meta" => %{ | ||
"page_number" => 3, | ||
"limit" => 1, | ||
"total_count" => 420, | ||
"total_pages" => 69 | ||
} | ||
} | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.Page do | ||
alias OpenApiSpex.Schema | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "Page", | ||
description: "Page metadata", | ||
type: :object, | ||
properties: %{ | ||
page_number: %Schema{type: :integer, description: "Current page number", default: 1}, | ||
limit: %Schema{type: :integer, description: "Max results per page", default: 25}, | ||
total_count: %Schema{type: :integer, description: "Total count of results", readOnly: true}, | ||
total_pages: %Schema{type: :integer, description: "Total count of pages", readOnly: true} | ||
}, | ||
example: %{ | ||
"page_number" => 3, | ||
"limit" => 25, | ||
"total_count" => 420, | ||
"total_pages" => 69 | ||
} | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.Score do | ||
alias OpenApiSpex.Schema | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "Score", | ||
description: "A Representation of a Score", | ||
type: :object, | ||
properties: %{ | ||
rating_type: %Schema{type: :string, description: "Rating Type", enum: ["micro_g", "native"]}, | ||
numenator: %Schema{type: :number, description: "Numenator"}, | ||
denominator: %Schema{type: :integer, description: "Denominator"}, | ||
total_count: %Schema{type: :string, description: "Total count of ratings"} | ||
}, | ||
example: %{ | ||
"numerator" => 4.0, | ||
"denominator" => 4, | ||
"rating_type" => "micro_g", | ||
"total_count" => 69 | ||
} | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule PlexusWeb.API.V1.Schemas.Scores do | ||
alias PlexusWeb.API.V1.Schemas.Score | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
title: "Scores", | ||
description: "A Representation of Scores", | ||
type: :object, | ||
properties: %{ | ||
micro_g: Score, | ||
native: Score | ||
}, | ||
derive?: false, | ||
example: %{ | ||
"micro_g" => %{ | ||
"numerator" => 4.0, | ||
"denominator" => 4, | ||
"rating_type" => "micro_g", | ||
"total_count" => 69 | ||
}, | ||
"native" => %{ | ||
"numerator" => 3.7, | ||
"denominator" => 4, | ||
"rating_type" => "native", | ||
"total_count" => 69 | ||
} | ||
} | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters