Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
abe90e3
Bump CI dependencies (#655)
zorbash Mar 3, 2025
4a3f7a3
Add examples property to Schema (#654)
madjar Mar 7, 2025
439fadc
Document schema resolver duplicate titles behaviour (#656)
zorbash Mar 7, 2025
02d8c15
Add spec.yaml tasks to example applications (#657)
zorbash Mar 7, 2025
fa34dd0
Fix 1.18 compilation warnings (#665)
zorbash May 25, 2025
22f46f5
Check for ex_doc warnings in CI and bump devtest deps (#666)
zorbash May 26, 2025
410f3aa
Test array query params in example phoenix app (#667)
zorbash May 26, 2025
2069321
Release 3.21.3
zorbash Jun 25, 2025
572130d
Fix OTP-28 support (#672)
bopm Jul 1, 2025
61d5951
Release version 3.21.4
zorbash Jul 1, 2025
c71c312
Fix assert_operation_response/2 references (#673)
zorbash Jul 8, 2025
bc1606b
Release version 3.21.5
zorbash Jul 8, 2025
9967e2f
Support multiple apps in Plug.SwaggerUI (#676)
zorbash Jul 30, 2025
7de53cb
Validate keys given to operation/2 macro (#675)
xxdavid Jul 31, 2025
be4f59a
Release version 3.22.0
zorbash Aug 5, 2025
aaee4a7
Fix elixir 1.19 support (#685)
adamcstephens Nov 18, 2025
32a7af0
Release version 3.22.1
zorbash Nov 21, 2025
1519adf
fix: type warnings Elixir 1.19 (#693)
davydog187 Dec 31, 2025
f2c71bf
Release version 3.22.2
zorbash Jan 8, 2026
224d1e1
chore: removed unused require(s) (#700)
David-Klemenc Apr 28, 2026
1377df0
Relax decimal requirement (#702)
josevalim May 5, 2026
8850f32
Release version 3.22.3
zorbash May 5, 2026
b2ed58b
Make layout configurable in Swagger UI (#704)
joshk Jul 6, 2026
2beb005
Merge upstream open-api-spex/master into fork master
aspett-remote Aug 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
otp: ["26"]
elixir: ["1.16"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: beam
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: PLT cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
Expand All @@ -34,20 +34,22 @@ jobs:
- run: mix compile --warnings-as-errors
- run: mix format --check-formatted
- run: mix credo --strict --all
- run: mix dialyzer
- run: mix dialyzer --format github
- run: mix docs --warnings-as-errors

test_examples:
runs-on: ubuntu-latest
name: Test Sample Applications
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: beam
with:
otp-version: 26
elixir-version: 1.16
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plug-build
Expand All @@ -61,28 +63,28 @@ jobs:
run: mix do deps.get, test

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
name: Test (OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}})
strategy:
matrix:
otp: ["23", "24", "25", "26"]
elixir: ["1.14", "1.15", "1.16"]
otp: ["24", "25", "26"]
elixir: ["1.14", "1.15", "1.16", "1.18"]
# Test each elixir version with lowest and highest compatible OTP version, exclude others
# See https://hexdocs.pm/elixir/compatibility-and-deprecations.html#between-elixir-and-erlang-otp
exclude:
- { otp: "24", elixir: "1.14" }
- { otp: "24", elixir: "1.18" }
- { otp: "25", elixir: "1.14" }
- { otp: "23", elixir: "1.15" }
- { otp: "25", elixir: "1.15" }
- { otp: "23", elixir: "1.16" }
- { otp: "25", elixir: "1.16" }
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: beam
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-build
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v3.22.3 - 2026-05-05

* chore: removed unused require(s) by @David-Klemenc in https://github.com/open-api-spex/open_api_spex/pull/700
* Relax decimal requirement by @josevalim in https://github.com/open-api-spex/open_api_spex/pull/702

## v3.22.2 - 2026-01-08

* fix: type warnings Elixir 1.19 by @davydog187 in https://github.com/open-api-spex/open_api_spex/pull/693

## v3.22.1 - 2025-11-21

* Fix elixir 1.19 support by @adamcstephens in https://github.com/open-api-spex/open_api_spex/pull/685

## v3.22.0 - 2025-08-05

* Support multiple apps in Plug.SwaggerUI by @zorbash in https://github.com/open-api-spex/open_api_spex/pull/676
* Validate keys given to operation/2 macro by @xxdavid in https://github.com/open-api-spex/open_api_spex/pull/675

## v3.21.5 - 2025-07-08

* Fix assert_operation_response/2 references by @zorbash in https://github.com/open-api-spex/open_api_spex/pull/673

## v3.21.4 - 2025-07-01

* Fix OTP-28 support by @bopm in https://github.com/open-api-spex/open_api_spex/pull/672

## v3.21.3 - 2025-06-25

* Fix cast x-validate when decoded schema by @GPrimola in https://github.com/open-api-spex/open_api_spex/pull/647
* Add examples property to Schema by @madjar in https://github.com/open-api-spex/open_api_spex/pull/654
* Document schema resolver duplicate titles behaviour by @zorbash in https://github.com/open-api-spex/open_api_spex/pull/656
* Fix 1.18 compilation warnings by @zorbash in https://github.com/open-api-spex/open_api_spex/pull/665

## v3.21.2 - 2024-10-02

Expand Down
15 changes: 13 additions & 2 deletions examples/phoenix_app/lib/phoenix_app/accounts/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ defmodule PhoenixApp.Accounts do
alias PhoenixApp.Accounts.User
alias PhoenixApp.Repo

def list_users() do
Repo.all(User)
import Ecto.Query

def list_users(filters) do
query = from(u in User, order_by: [asc: u.id])

query =
if filters[:ids] do
from(u in query, where: u.id in ^filters[:ids])
else
query
end

Repo.all(query)
end

def get_user!(id) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ defmodule PhoenixAppWeb.UserController do
operation :index,
summary: "List users",
description: "List all users",
parameters: [
OpenApiSpex.Operation.parameter(
:ids,
:query,
%Schema{type: :array, items: %Schema{type: :integer}},
"Filter by user ids"
)
],
responses: [
ok: {"User List Response", "application/json", Schemas.UsersResponse},
unprocessable_entity: %Reference{"$ref": "#/components/responses/unprocessable_entity"}
]

def index(conn, _params) do
users = Accounts.list_users()
def index(conn, params) do
users = Accounts.list_users(params)

render(conn, "index.json", users: users)
end

Expand All @@ -37,8 +46,7 @@ defmodule PhoenixAppWeb.UserController do
parameters: [
group_id: [in: :path, type: :integer, description: "Group ID", example: 1]
],
request_body:
{"The user attributes", "application/json", Schemas.UserRequest, required: true},
request_body: {"The user attributes", "application/json", Schemas.UserRequest, required: true},
responses: [
created: {"User", "application/json", Schemas.UserResponse}
]
Expand Down Expand Up @@ -88,8 +96,7 @@ defmodule PhoenixAppWeb.UserController do
required: true
]
],
request_body:
{"The user attributes", "application/json", Schemas.UserRequest, required: true},
request_body: {"The user attributes", "application/json", Schemas.UserRequest, required: true},
responses: [
ok: {"User", "application/json", Schemas.UserResponse}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ defmodule PhoenixAppWeb.UserControllerWithStructSpecs do
of using the ExDoc-based operation specs.
"""
use PhoenixAppWeb, :controller

import OpenApiSpex.Operation, only: [parameter: 5, request_body: 4, response: 3]
alias OpenApiSpex.{Operation, Reference}

alias OpenApiSpex.{Operation, Reference, Schema}
alias PhoenixApp.{Accounts, Accounts.User}
alias PhoenixAppWeb.Schemas

Expand Down Expand Up @@ -34,15 +36,24 @@ defmodule PhoenixAppWeb.UserControllerWithStructSpecs do
summary: "List users",
description: "List all useres",
operationId: "UserController.index",
parameters: [
OpenApiSpex.Operation.parameter(
:ids,
:query,
%Schema{type: :array, items: %Schema{type: :integer}},
"Filter by user ids"
)
],
responses: %{
200 => response("User List Response", "application/json", Schemas.UsersResponse),
422 => %Reference{"$ref": "#/components/responses/unprocessable_entity"}
}
}
end

def index(conn, _params) do
users = Accounts.list_users()
def index(conn, params) do
users = Accounts.list_users(params)

render(conn, "index.json", users: users)
end

Expand All @@ -56,9 +67,7 @@ defmodule PhoenixAppWeb.UserControllerWithStructSpecs do
Operation.parameter(:group_id, :path, :integer, "Group ID", example: 1)
],
requestBody:
request_body("The user attributes", "application/json", Schemas.UserRequest,
required: true
),
request_body("The user attributes", "application/json", Schemas.UserRequest, required: true),
responses: %{
201 => response("User", "application/json", Schemas.UserResponse)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/phoenix_app/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ defmodule PhoenixApp.Mixfile do
defp aliases() do
[
test: ["ecto.create --quiet", "ecto.migrate", "test"],
spec: ["openapi.spec.json --spec PhoenixAppWeb.ApiSpec \"priv/static/swagger.json\""]
spec: ["openapi.spec.json --spec PhoenixAppWeb.ApiSpec \"priv/static/swagger.json\""],
"spec.yaml": ["openapi.spec.yaml --spec PhoenixAppWeb.ApiSpec \"priv/static/swagger.yaml\""]
]
end

Expand All @@ -48,6 +49,7 @@ defmodule PhoenixApp.Mixfile do
{:phoenix_view, "~> 2.0"},
{:plug_cowboy, "~> 2.0"},
{:jason, "~> 1.0"},
{:ymlr, "~> 5.0"},
{:dialyxir, "1.0.0-rc.6", only: [:dev], runtime: false}
]
end
Expand Down
Loading
Loading