Skip to content

Commit

Permalink
fix: handle oas 3.0 optionality
Browse files Browse the repository at this point in the history
  • Loading branch information
javiergarea committed Jan 10, 2024
1 parent 213e2f0 commit 11b16b1
Show file tree
Hide file tree
Showing 13 changed files with 1,186 additions and 783 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: erf ci
name: CI

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ A detailed description of each parameter can be found in the following list:
- `callback`: Name of the callback module.
- `port`: Port the server will listen to. Defaults to `8080`.
- `name`: Name under which the server is registered. Defaults to `erf`.
- `spec_parser`: Name of the specification parser module. Defaults to `erf_oas_3_0`.
- `spec_parser`: Name of the specification parser module. Defaults to `erf_parser_oas_3_0`.
- `preprocess_middlewares`: List of names of middlewares to be invoked before the request is forwarded to the callback. Defaults to `[]`.
- `postprocess_middlewares`: List of names of middlewares to be invoked after the response is returned by the callback. Defaults to `[]`.
- `ssl`: Boolean flag that enables/disables SSL. Defaults to `false`.
Expand Down
12 changes: 9 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

{deps, [
{elli, {git, "[email protected]:elli-lib/elli.git", {branch, "main"}}},
{ndto, {git, "[email protected]:nomasystems/ndto.git", {branch, "main"}}},
{ndto, {git, "[email protected]:nomasystems/ndto.git", {tag, "0.2.0"}}},
{njson, {git, "[email protected]:nomasystems/njson.git", {branch, "main"}}}
]}.

{plugins, [
{rebar3_ndto, {git, "[email protected]:nomasystems/rebar3_ndto.git", {branch, "main"}}}
{rebar3_ndto, {git, "[email protected]:nomasystems/rebar3_ndto.git", {tag, "0.2.0"}}}
]}.
{ndto, [
{specs, [
Expand All @@ -27,6 +27,9 @@

{project_plugins, [
{erlfmt, {git, "[email protected]:WhatsApp/erlfmt.git", {branch, "main"}}},
{eqwalizer_rebar3,
{git_subdir, "https://github.com/whatsapp/eqwalizer.git", {branch, "main"},
"eqwalizer_rebar3"}},
{gradualizer, {git, "[email protected]:josefs/Gradualizer.git", {branch, "master"}}},
rebar3_ex_doc
]}.
Expand All @@ -42,6 +45,9 @@
{test, [
{erl_opts, [nowarn_export_all]},
{deps, [
{eqwalizer_support,
{git_subdir, "https://github.com/whatsapp/eqwalizer.git", {branch, "main"},
"eqwalizer_support"}},
{meck, {git, "[email protected]:eproxus/meck.git", {branch, "master"}}},
{nct_util, {git, "[email protected]:nomasystems/nct_util.git", {branch, "main"}}}
]}
Expand Down Expand Up @@ -91,5 +97,5 @@

{gradualizer_opts, [
%% TODO: address
{exclude, ["src/erf_oas_3_0.erl", "src/erf_router.erl"]}
{exclude, ["src/erf_parser_oas_3_0.erl", "src/erf_router.erl"]}
]}.
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
1},
{<<"ndto">>,
{git,"[email protected]:nomasystems/ndto.git",
{ref,"491a2441e43afa2fb037c6e7e826c45a383e3bd9"}},
{ref,"ecb52baafa44eba1d58661e4658e34b011aeb58c"}},
0},
{<<"njson">>,
{git,"[email protected]:nomasystems/njson.git",
{ref,"76ab40033ee977f876e7b3addca5de981ff4a9ef"}},
{ref,"b230b3e6fb5e35320aeaa203762f3f12277c9970"}},
0}].
4 changes: 2 additions & 2 deletions src/erf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

%%% TYPES
-type api() :: erf_parser:api().
-type body() :: njson:t().
-type body() :: undefined | njson:t().
-type conf() :: #{
spec_path := binary(),
callback := module(),
Expand Down Expand Up @@ -207,7 +207,7 @@ reload_conf(Name, NewConf) ->
init([Name, RawConf]) ->
RawErfConf = #{
spec_path => maps:get(spec_path, RawConf),
spec_parser => maps:get(spec_parser, RawConf, erf_oas_3_0),
spec_parser => maps:get(spec_parser, RawConf, erf_parser_oas_3_0),
callback => maps:get(callback, RawConf),
static_routes => maps:get(static_routes, RawConf, []),
swagger_ui => maps:get(swagger_ui, RawConf, false),
Expand Down
Loading

0 comments on commit 11b16b1

Please sign in to comment.