Skip to content

Commit 0be1f73

Browse files
committed
Initial Elixir library setup
- Create library structure with mix.exs - Add phoenix_swagger and zoi dependencies - Configure package metadata with Apache-2.0 license - Add basic README with project overview - Setup GitHub Actions CI for testing on Elixir 1.17/OTP 27 and 1.19/OTP 28 - Add formatter check to CI pipeline - Configure development environment with .tool-versions
1 parent 1e14340 commit 0be1f73

9 files changed

Lines changed: 236 additions & 2 deletions

File tree

‎.formatter.exs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

‎.github/workflows/ci.yml‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
include:
16+
- elixir: '1.17'
17+
otp: '27'
18+
- elixir: '1.19'
19+
otp: '28'
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Elixir
26+
uses: erlef/setup-beam@v1
27+
with:
28+
elixir-version: ${{ matrix.elixir }}
29+
otp-version: ${{ matrix.otp }}
30+
31+
- name: Restore dependencies cache
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
deps
36+
_build
37+
key: ${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}-
40+
41+
- name: Install dependencies
42+
run: mix deps.get
43+
44+
- name: Compile dependencies
45+
run: mix deps.compile
46+
47+
- name: Compile application
48+
run: mix compile --warnings-as-errors
49+
50+
- name: Run tests
51+
run: mix test
52+
53+
format:
54+
name: Format
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Elixir
62+
uses: erlef/setup-beam@v1
63+
with:
64+
elixir-version: '1.19'
65+
otp-version: '28'
66+
67+
- name: Restore dependencies cache
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
deps
72+
_build
73+
key: ${{ runner.os }}-mix-format-${{ hashFiles('**/mix.lock') }}
74+
restore-keys: |
75+
${{ runner.os }}-mix-format-
76+
77+
- name: Install dependencies
78+
run: mix deps.get
79+
80+
- name: Check formatting
81+
run: mix format --check-formatted

‎.tool-versions‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
elixir 1.19.4-otp-28
2+
erlang 28.3
3+

‎README.md‎

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# zoi_phoenix_swagger
2-
TODO
1+
# ZoiPhoenixSwagger
2+
3+
Integration library between [Zoi](https://github.com/phcurado/zoi) and [Phoenix Swagger](https://github.com/xerions/phoenix_swagger) for automatic parameter validation and OpenAPI documentation generation.
4+
5+
## Overview
6+
7+
ZoiPhoenixSwagger bridges the gap between Zoi's runtime parameter validation and Phoenix Swagger's OpenAPI documentation generation. Define your parameter schemas once using Zoi, and automatically generate both validation logic and Swagger/OpenAPI documentation.
8+
9+
## Features
10+
11+
- Define controller parameters using Zoi schemas
12+
- Automatically generate Phoenix Swagger parameter definitions from Zoi schemas
13+
- Maintain a single source of truth for parameter validation and API documentation
14+
- Type-safe parameter validation with comprehensive error messages
15+
16+
## Installation
17+
18+
Add `zoi_phoenix_swagger` to your list of dependencies in `mix.exs`:
19+
20+
```elixir
21+
def deps do
22+
[
23+
{:zoi_phoenix_swagger, "~> 0.1.0"}
24+
]
25+
end
26+
```
27+
28+
## Usage
29+
30+
Coming soon.
31+
32+
## Development
33+
34+
### Running Tests
35+
36+
```bash
37+
mix test
38+
```
39+
40+
### Code Formatting
41+
42+
```bash
43+
mix format
44+
```
45+
46+
## Contributing
47+
48+
Contributions are welcome! Please feel free to submit a Pull Request.
49+
50+
## License
51+
52+
Copyright 2026
53+
54+
Licensed under the Apache License, Version 2.0 (the "License");
55+
you may not use this file except in compliance with the License.
56+
You may obtain a copy of the License at
57+
58+
http://www.apache.org/licenses/LICENSE-2.0
59+
60+
Unless required by applicable law or agreed to in writing, software
61+
distributed under the License is distributed on an "AS IS" BASIS,
62+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63+
See the License for the specific language governing permissions and
64+
limitations under the License.

‎lib/zoi_phoenix_swagger.ex‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
defmodule ZoiPhoenixSwagger do
2+
@moduledoc """
3+
Documentation for `ZoiPhoenixSwagger`.
4+
"""
5+
6+
@doc """
7+
Hello world.
8+
9+
## Examples
10+
11+
iex> ZoiPhoenixSwagger.hello()
12+
:world
13+
14+
"""
15+
def hello do
16+
:world
17+
end
18+
end

‎mix.exs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
defmodule ZoiPhoenixSwagger.MixProject do
2+
use Mix.Project
3+
4+
def project do
5+
[
6+
app: :zoi_phoenix_swagger,
7+
version: "0.1.0",
8+
elixir: "~> 1.17",
9+
start_permanent: Mix.env() == :prod,
10+
deps: deps(),
11+
description: description(),
12+
package: package(),
13+
source_url: "https://github.com/nirev/zoi_phoenix_swagger"
14+
]
15+
end
16+
17+
# Run "mix help compile.app" to learn about applications.
18+
def application do
19+
[
20+
extra_applications: [:logger]
21+
]
22+
end
23+
24+
# Run "mix help deps" to learn about dependencies.
25+
defp deps do
26+
[
27+
{:phoenix_swagger, "~> 0.8"},
28+
{:zoi, "~> 0.1"},
29+
{:ex_doc, "~> 0.31", only: :dev, runtime: false}
30+
]
31+
end
32+
33+
defp description do
34+
"Integration library between Zoi and Phoenix Swagger for automatic parameter validation and OpenAPI documentation generation."
35+
end
36+
37+
defp package do
38+
[
39+
licenses: ["Apache-2.0"],
40+
links: %{"GitHub" => "https://github.com/nirev/zoi_phoenix_swagger"}
41+
]
42+
end
43+
end

‎mix.lock‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
%{
2+
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
3+
"ex_doc": {:hex, :ex_doc, "0.39.3", "519c6bc7e84a2918b737aec7ef48b96aa4698342927d080437f61395d361dcee", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "0590955cf7ad3b625780ee1c1ea627c28a78948c6c0a9b0322bd976a079996e1"},
4+
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
5+
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
6+
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
7+
"mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"},
8+
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
9+
"phoenix_swagger": {:hex, :phoenix_swagger, "0.8.5", "2141114352cd7f352b21c6662e5ae7539c78dfea33f12c50c3176c4b75b8fbed", [:mix], [{:ex_json_schema, "~> 0.9", [hex: :ex_json_schema, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 6.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm", "2c62b8a7d3bdd5a65a0dfb7598ef75d7965ddc4f97e1ee075184c2c35d3acc62"},
10+
"plug": {:hex, :plug, "1.19.1", "09bac17ae7a001a68ae393658aa23c7e38782be5c5c00c80be82901262c394c0", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "560a0017a8f6d5d30146916862aaf9300b7280063651dd7e532b8be168511e62"},
11+
"plug_crypto": {:hex, :plug_crypto, "2.1.1", "19bda8184399cb24afa10be734f84a16ea0a2bc65054e23a62bb10f06bc89491", [:mix], [], "hexpm", "6470bce6ffe41c8bd497612ffde1a7e4af67f36a15eea5f921af71cf3e11247c"},
12+
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
13+
"zoi": {:hex, :zoi, "0.14.1", "e1311b4a156bc72e970df72f69b11a40f66ef204ace2e3c38b72a6abae2f9ecc", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "65bb61fd0fd3d6ff75856ccec7b638d159b20f204382b674f8089c050d7f6729"},
14+
}

‎test/test_helper.exs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ExUnit.start()

‎test/zoi_phoenix_swagger_test.exs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
defmodule ZoiPhoenixSwaggerTest do
2+
use ExUnit.Case
3+
doctest ZoiPhoenixSwagger
4+
5+
test "greets the world" do
6+
assert ZoiPhoenixSwagger.hello() == :world
7+
end
8+
end

0 commit comments

Comments
 (0)