Skip to content

Commit 4ef6291

Browse files
committed
Update OpenApiSpex docs
1 parent b1dab7e commit 4ef6291

6 files changed

Lines changed: 162 additions & 6 deletions

File tree

lib/swapi_web/controllers/film_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.FilmController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.Films
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.FilmController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of films", "application/json", SWAPIWeb.Schemas.FilmList}

lib/swapi_web/controllers/person_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.PersonController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.People
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.PersonController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of people", "application/json", SWAPIWeb.Schemas.PersonList}

lib/swapi_web/controllers/planet_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.PlanetController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.Planets
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.PlanetController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of planets", "application/json", SWAPIWeb.Schemas.PlanetList}

lib/swapi_web/controllers/species_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.SpeciesController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.Species
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.SpeciesController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of species", "application/json", SWAPIWeb.Schemas.SpeciesList}

lib/swapi_web/controllers/starship_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.StarshipController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.Starships
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.StarshipController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of starships", "application/json", SWAPIWeb.Schemas.StarshipList}

lib/swapi_web/controllers/vehicle_controller.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule SWAPIWeb.VehicleController do
22
use SWAPIWeb, :controller
33
use OpenApiSpex.ControllerSpecs
44

5+
alias OpenApiSpex.Schema
56
alias SWAPI.Vehicles
67

78
import SWAPIWeb.Util
@@ -19,7 +20,32 @@ defmodule SWAPIWeb.VehicleController do
1920
"One or more search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched. Searches may contain quoted phrases with spaces, each phrase is considered as a single search term.",
2021
type: :string
2122
],
22-
page: [in: :query, description: "Page number", type: :integer]
23+
page: [
24+
in: :query,
25+
description: "Page number. Cannot be used together with `offset`.",
26+
schema: %Schema{
27+
type: :integer,
28+
minimum: 1,
29+
default: 1
30+
}
31+
],
32+
offset: [
33+
in: :query,
34+
description: "Offset of the first item. Cannot be used together with `page`.",
35+
schema: %Schema{
36+
type: :integer,
37+
minimum: 0
38+
}
39+
],
40+
limit: [
41+
in: :query,
42+
description: "Maximum number of items to return in the response.",
43+
schema: %Schema{
44+
type: :integer,
45+
minimum: 1,
46+
default: 10
47+
}
48+
]
2349
],
2450
responses: [
2551
ok: {"List of vehicles", "application/json", SWAPIWeb.Schemas.VehicleList}

0 commit comments

Comments
 (0)